diff --git a/Hello3D/BuildQt/mainwindow.cpp b/Hello3D/BuildQt/mainwindow.cpp index 00b3ceeae8b91cb409dbdc967dd4636e13e4d1b1..8d438b9419c08502bb68c06c95eb31cf0afaf563 100644 --- a/Hello3D/BuildQt/mainwindow.cpp +++ b/Hello3D/BuildQt/mainwindow.cpp @@ -48,6 +48,11 @@ void MainWindow::init() QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(30);//30ms + + label = new QLabel; + label->setParent(this); + label->setFixedWidth(UI_WIDTH); + label->setFixedHeight(UI_HEIGHT); } void MainWindow::paintEvent(QPaintEvent* p) @@ -56,9 +61,8 @@ void MainWindow::paintEvent(QPaintEvent* p) static bool force_update = true; void* fb = getUiOfHello3D(NULL, NULL, force_update); if(fb){ - QPainter painter(this); QImage img((uchar*)fb, UI_WIDTH, UI_HEIGHT, QImage::Format_RGB16); - painter.drawImage(0, 0, img); + label->setPixmap(QPixmap::fromImage(img)); force_update = false; } } diff --git a/Hello3D/BuildQt/mainwindow.h b/Hello3D/BuildQt/mainwindow.h index b8b27148fc957b0501611a89a6a9cdd5bc952477..23300232392c50dc53a3cd22d5b60d5d90d98709 100644 --- a/Hello3D/BuildQt/mainwindow.h +++ b/Hello3D/BuildQt/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include namespace Ui { class MainWindow; @@ -23,6 +24,8 @@ public: private: bool m_is_pressed; Ui::MainWindow *ui; + + QLabel *label; }; #endif // MAINWINDOW_H