AboutView.cpp 989 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. QWidget::showEvent(event);
  16. initialize();
  17. }
  18. void AboutView::resizeEvent(QResizeEvent *event)
  19. {
  20. QWidget::resizeEvent(event);
  21. initialize();
  22. m_bgLabel->resize(event->size());
  23. m_bgLabel->setPixmap(pixmap.scaled(width(), height(), Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
  24. }
  25. void AboutView::initialize()
  26. {
  27. if (m_initilized == true) {
  28. return;
  29. }
  30. m_bgLabel = new QLabel(this);
  31. pixmap = QPixmap(":/resource/background/1.jpg");
  32. m_vBoxLayout = new QVBoxLayout(this);
  33. m_appInfoWidget = new AppInfoWidget(this);
  34. m_vBoxLayout->addWidget(m_appInfoWidget);
  35. m_initilized = true;
  36. }