如果我只是从 QGraphicsView 开始,它会显示。但是如果我将 QGraphicView 放在 mainwindow.cpp 中,它会闪烁并消失??
int main(int argc, char **argv)
{
QApplication a(argc, argv);
QGraphicsView view;
view.resize(1000, 800);
view.show();
return a.exec();
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPushButton *m_button1 = new QPushButton("1", this);
m_button1->setGeometry(QRect(QPoint(100, 100), QSize(100, 100)));
connect(m_button1, SIGNAL(released()), this, SLOT(handleButton1()));
}
void MainWindow::handleButton1()
{
QGraphicsView view;
view.resize(1000, 800);
view.show();
}