changeQuestion.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #include "changeQuestion.h"
  2. #include "ui_changeQuestion.h"
  3. #include <QFile>
  4. #include "CAppInfo.h"
  5. changeQuestion::changeQuestion(QWidget *parent) :
  6. QWidget(parent),
  7. ui(new Ui::changeQuestion)
  8. {
  9. ui->setupUi(this);
  10. setAttribute(Qt::WA_DeleteOnClose);
  11. // QFile qssFile(":/qss/main.qss");
  12. // qssFile.open(QFile::ReadOnly);
  13. // QString qss;
  14. // qss = qssFile.readAll();
  15. // setStyleSheet(qss);
  16. setStyleSheet(g_appInfoPtr->m_sQssStr);
  17. }
  18. void changeQuestion::showBtn(int nType)
  19. {
  20. sStyle = QString(R"(QPushButton
  21. {
  22. outline:none;
  23. background:rgba(19,187,138,1);
  24. border-radius:%1px;
  25. font-size:%2px;
  26. font-family:"Microsoft YaHei";
  27. font-weight:600;
  28. color:rgba(255,255,255,1);
  29. })").arg((int)(g_appInfoPtr->m_fRate*10))
  30. .arg((int)(g_appInfoPtr->m_fRate*12));
  31. sDisableStyle = QString(R"(QPushButton
  32. {
  33. outline:none;
  34. background:rgba(239,240,245,1);
  35. border-radius:%1px;
  36. font-size:%2px;
  37. font-family:"Microsoft YaHei";
  38. font-weight:600;
  39. color:rgba(153,153,153,1);
  40. })").arg((int)(g_appInfoPtr->m_fRate*10))
  41. .arg((int)(g_appInfoPtr->m_fRate*12));
  42. ui->btn_cq_previous->setStyleSheet(sStyle);
  43. ui->btn_cq_next->setStyleSheet(sStyle);
  44. ui->btn_cq_previous->setEnabled(true);
  45. ui->btn_cq_next->setEnabled(true);
  46. if(nType == 1)
  47. {
  48. ui->btn_cq_previous->setStyleSheet(sDisableStyle);
  49. ui->btn_cq_previous->setEnabled(false);
  50. }
  51. else if(nType == 2)
  52. {
  53. ui->btn_cq_next->setStyleSheet(sDisableStyle);
  54. ui->btn_cq_next->setEnabled(false);
  55. }
  56. }
  57. changeQuestion::~changeQuestion()
  58. {
  59. delete ui;
  60. }
  61. void changeQuestion::setUI(const int nLeft, const int nTop, const int nWidth, const int nHeight)
  62. {
  63. setGeometry(nLeft, nTop, nWidth, nHeight);
  64. QIcon icon(QPixmap(":/images/btn-icon-previous.png"));
  65. ui->btn_cq_previous->setIcon(icon);
  66. ui->btn_cq_previous->setGeometry(g_appInfoPtr->m_fRate*80, nHeight - g_appInfoPtr->m_fRate*32, g_appInfoPtr->m_fRate*100, g_appInfoPtr->m_fRate*32);
  67. QIcon icon1(QPixmap(":/images/btn-icon-next.png"));
  68. ui->btn_cq_next->setIcon(icon1);
  69. ui->btn_cq_next->setGeometry(ui->btn_cq_previous->x() + ui->btn_cq_previous->width() + g_appInfoPtr->m_fRate*20,
  70. ui->btn_cq_previous->y(), ui->btn_cq_previous->width(), ui->btn_cq_previous->height());
  71. }
  72. void changeQuestion::on_btn_cq_previous_clicked()
  73. {
  74. ui->btn_cq_previous->setStyleSheet(sDisableStyle);
  75. ui->btn_cq_next->setStyleSheet(sDisableStyle);
  76. ui->btn_cq_previous->setEnabled(false);
  77. ui->btn_cq_next->setEnabled(false);
  78. emit previousQuestion();
  79. }
  80. void changeQuestion::on_btn_cq_next_clicked()
  81. {
  82. ui->btn_cq_previous->setStyleSheet(sDisableStyle);
  83. ui->btn_cq_next->setStyleSheet(sDisableStyle);
  84. ui->btn_cq_previous->setEnabled(false);
  85. ui->btn_cq_next->setEnabled(false);
  86. emit nextQuestion();
  87. }