AboutView.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "AboutView.h"
  2. #include "AppInfoWidget.h"
  3. #include <QBoxLayout>
  4. #include <QApplication>
  5. #include <QPainter>
  6. #include <QLabel>
  7. #include <QResizeEvent>
  8. #include <QDebug>
  9. AboutView::AboutView(QWidget *parent) : QWidget(parent)
  10. {
  11. setWindowTitle("关于");
  12. }
  13. void AboutView::showEvent(QShowEvent *event)
  14. {
  15. qDebug() << __FUNCTION__;
  16. QWidget::showEvent(event);
  17. initialize();
  18. }
  19. void AboutView::hideEvent(QHideEvent *event)
  20. {
  21. qDebug() << __FUNCTION__ << __LINE__ << endl;
  22. QWidget::hideEvent(event);
  23. }
  24. void AboutView::resizeEvent(QResizeEvent *event)
  25. {
  26. QWidget::resizeEvent(event);
  27. initialize();
  28. m_bgLabel->resize(event->size());
  29. m_bgLabel->setPixmap(pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
  30. }
  31. void AboutView::initialize()
  32. {
  33. if (m_initilized == true) {
  34. return;
  35. }
  36. m_bgLabel = new QLabel(this);
  37. pixmap = QPixmap(":/resource/background/1.jpg");
  38. m_vBoxLayout = new QVBoxLayout(this);
  39. m_appInfoWidget = new AppInfoWidget(this);
  40. m_vBoxLayout->addWidget(m_appInfoWidget);
  41. m_initilized = true;
  42. }