为什么没有执行paintevent这个函数?
#include "mainwindow.h"#define cout qDebug() test :: test(QMainWindow *parent) : QMainWindow(parent){ setGeometry(320,320,320,320); mywidget = new QWidget; mywidget->setGeometry(320,320,320,320); setCentralWidget(mywidget); newaction = new QAction(tr("New Game"),this); connect(newaction,SIGNAL(triggered()),this,SLOT(newdraw())); aboutaction = new QAction(tr("About"),this); connect(aboutaction,SIGNAL(triggered()),this,SLOT(about())); filemenu = menuBar()->addMenu(tr("File")); filemenu->addSeparator(); filemenu -> addAction(newaction); aboutmenu = menuBar()->addMenu(tr("About")); aboutmenu->addSeparator(); aboutmenu->addAction(aboutaction); Test = new QPushButton(tr("aa"),this); connect(Test,SIGNAL(clicked()),this,SLOT(newdraw())); Test->setGeometry(32,32,32,32); isdraw = false; memset(arrmap,0,sizeof(arrmap)); photolist.clear(); for(int i = 1 ; i <= 5; i++) { QString phname = ":/image/"+QString::number(i,10)+".gif"; QPixmap pixmap(phname); photolist.append(pixmap); }} void test:: newdraw(){ isdraw = true; update();} void test :: paintevent(QPaintEvent */*event*/){ cout << "@@@@@@@@@@@@@@@@@";// 没有运行 if(!isdraw) return; QPainter painter(this); for(int i = 1; i <= 8; i++) { for(int j = 1 ; j <= 8; j++) { arrmap[j] = rand() % 5; } } for(int i = 1; i <= 8; i ++) { for(int j =1; j <= 8; j++) { painter.drawPixmap((j-1)*(32),(i-1)*(32),32,32,photolist.at(arrmap[j])); } } painter.drawEllipse(32,32,32,32); update();}