qt重写了QFrame的paintEvent,怎么才能显示出来
想在qrame中画图,就从QFrame继承得到了一个新类myframe,重写了paintEvent
然后在mainwindow定义中添加了一行 myframe *frame;
,现在的问题是怎么让frame在主窗口上显示
如下
//mainwindow.cppMainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); frame= new MyFrame();//这样写就新弹出一个新窗口 ,显示正常,但不是在主窗口内 frame.show();}//第二种写法MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); frame= new MyFrame(this);//这样写就什么都不显示了 frame.show();}