I derive a subclass from QMainWindow, I want to set the QGraphicsView object as the mainwindow's centralWidget, like below:
int main(int argc, char *argv[])
{
test w;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
test
::test(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
pixCT.load("Resources/CT.bmp");
setCentralWidget(&view);
scene.addPixmap(pixCT);
//view.show();
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
test w;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
test::test(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
QPixmap pixCT;
pixCT.load("Resources/CT.bmp");
QGraphicsScene scene;
QGraphicsView view(&scene, this);
setCentralWidget(&view);
scene.addPixmap(pixCT);
//view.show();
}
To copy to clipboard, switch view to plain text mode
But it doesn't work. What should I do to solve this problem ?
Thank you very much for helping!
Bookmarks