I build a widget has a qlabel, below is its constructor
Qt Code:
#ifndef VIEWER_H #define VIEWER_H #include <iostream> #include <QWidget> #include <QPixmap> #include <QLabel> #include <QImage> #include <QVBoxLayout> using namespace std; { Q_OBJECT public: public slots: void setIplImage(); private: QVBoxLayout *mainLayout; QLabel *movieLabel; }; #endif { movieLabel->setAlignment(Qt::AlignCenter); movieLabel->setAutoFillBackground(true); movieLabel->setScaledContents(true); mainLayout->addWidget(movieLabel); setLayout(mainLayout); } void Viewer::setIplImage() { //image.save("test2.jpg"); //it works movieLabel->setPixmap(QPixmap::fromImage(image)); //compile success but runtime error with access violation. }To copy to clipboard, switch view to plain text mode
and if i use it in constructor, the setPixmap() can run.
Thanks for any comments
Bookmarks