welcomeWidget.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include "welcomeWidget.h"
  2. #include "ui_welcomeWidget.h"
  3. #include <QDesktopWidget>
  4. #include "CAppInfo.h"
  5. welcomeWidget::welcomeWidget(QString sStudentName, QString sStudentCode,
  6. QString sSpecialtyName, QWidget *parent) :
  7. QWidget(parent),
  8. ui(new Ui::welcomeWidget)
  9. {
  10. ui->setupUi(this);
  11. setWindowFlags(Qt::FramelessWindowHint);
  12. setStyleSheet(g_appInfoPtr->m_sQssStr);
  13. ui->label_wcw_studentName->setText(QString::fromLocal8Bit("姓名:%1-%2").arg(sStudentName).arg(sStudentCode));
  14. ui->label_wcw_specialty->setText(QString::fromLocal8Bit("专业:%1").arg(sSpecialtyName));
  15. initUI();
  16. }
  17. welcomeWidget::~welcomeWidget()
  18. {
  19. delete ui;
  20. }
  21. void welcomeWidget::initUI()
  22. {
  23. QDesktopWidget *dekwiget = QApplication::desktop();
  24. setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  25. ui->widget_mask->setGeometry(0, 0, dekwiget->width(), dekwiget->height());
  26. ui->widget_wcw_BG->setGeometry((width() - g_appInfoPtr->m_fRate*100)/2, (height() - g_appInfoPtr->m_fRate*212)/2,
  27. g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*212);
  28. ui->label_wcw_icon->setGeometry(g_appInfoPtr->m_fRate*30, g_appInfoPtr->m_fRate*30,
  29. g_appInfoPtr->m_fRate*40, g_appInfoPtr->m_fRate*40);
  30. ui->label_wcw_tips->adjustSize();
  31. ui->label_wcw_tips->setGeometry(ui->label_wcw_icon->x() + ui->label_wcw_icon->width() + g_appInfoPtr->m_fRate*20,
  32. ui->label_wcw_icon->y(), ui->label_wcw_tips->width(), ui->label_wcw_tips->height());
  33. ui->label_wcw_studentName->adjustSize();
  34. ui->label_wcw_studentName->setGeometry(ui->label_wcw_tips->x(), ui->label_wcw_tips->y() + ui->label_wcw_tips->height() + g_appInfoPtr->m_fRate*20,
  35. ui->label_wcw_studentName->width(), ui->label_wcw_studentName->height());
  36. ui->label_wcw_specialty->adjustSize();
  37. ui->label_wcw_specialty->setGeometry(ui->label_wcw_tips->x(), ui->label_wcw_studentName->y() + ui->label_wcw_studentName->height() + g_appInfoPtr->m_fRate*10,
  38. ui->label_wcw_specialty->width(), ui->label_wcw_specialty->height());
  39. int nWidth = ui->widget_wcw_BG->width();
  40. if (nWidth - g_appInfoPtr->m_fRate * 30 < ui->label_wcw_tips->x() + ui->label_wcw_tips->width())
  41. {
  42. nWidth = ui->label_wcw_tips->x() + ui->label_wcw_tips->width() + g_appInfoPtr->m_fRate * 30;
  43. }
  44. if(nWidth - g_appInfoPtr->m_fRate*30 < ui->label_wcw_studentName->x() + ui->label_wcw_studentName->width())
  45. {
  46. nWidth = ui->label_wcw_studentName->x() + ui->label_wcw_studentName->width() + g_appInfoPtr->m_fRate*30;
  47. }
  48. if(nWidth - g_appInfoPtr->m_fRate*30 < ui->label_wcw_specialty->x() + ui->label_wcw_specialty->width())
  49. {
  50. nWidth = ui->label_wcw_specialty->x() + ui->label_wcw_specialty->width() + g_appInfoPtr->m_fRate*30;
  51. }
  52. if(nWidth > ui->widget_wcw_BG->width())
  53. {
  54. ui->widget_wcw_BG->setGeometry((width() - nWidth)/2, (height() - g_appInfoPtr->m_fRate*212)/2,
  55. nWidth, g_appInfoPtr->m_fRate*212);
  56. }
  57. ui->btn_wcw_comfirm->setGeometry(ui->widget_wcw_BG->width() - g_appInfoPtr->m_fRate*(20 + 80), ui->widget_wcw_BG->height() - g_appInfoPtr->m_fRate*(20 + 30),
  58. g_appInfoPtr->m_fRate * 80, g_appInfoPtr->m_fRate * 30);
  59. }
  60. void welcomeWidget::on_btn_wcw_comfirm_clicked()
  61. {
  62. emit exitWelcomeWidget();
  63. }