为什么我觉得Qt在windows下各种问题呢?
在写一个很简单的实验程序,我想实现的无非是,当我点击next button时,中央的label里面的内容发生变化,不知道为什么编译能通过,但是无法实现,当我点击next button时还报Exception at 0xxxxxxxx, code: 0xc0000005: read access violation at: 0x0, flags=0x0
下面贴上相关代码:
/*experiment.h*/
#define initial_state 0
#define start_state 1
#define detect_state 2
#define pause_state 3
#define final_state 4
#pragma comment(lib, "Qt5Widgets.lib")
class Experiment:public QDialog{
Q_OBJECT
public:
Experiment(QWidget *parent=0);
protected:
void closeEvent(QCloseEvent *event);
private slots:
void ButtonFunction();
private:
//Thread cv;
//Thread mind;
QLabel *direction;
QPushButton *next;
int state;
};
#endif // EXPERIMENT_H
/*experiment.cpp*/
#include "experiment.h"
Experiment::Experiment(QWidget *parent): QDialog(parent){
state=initial_state;
QFont font("Courier",48,75,0);
direction=new QLabel(tr("This is a experiment"),this);
direction->setGeometry(450,400,760,73);
direction->setFont(font);
next=new QPushButton(tr("Next"),this);
next->setGeometry(1500,850,71,21);
next->setDefault(true);
connect(next, SIGNAL(clicked()), this, SLOT(ButtonFunction()));
}
void Experiment::ButtonFunction(){
switch(state){
case initial_state:
//TODO:
next->setText(tr("please do something change"));//完全不起作用
direction->setGeometry(450,400,1400,73);**
break;
case start_state:
//TODO:
break;
case detect_state:
//TODO:
break;
case pause_state:
//TODO:
break;
case final_state:
//TODO:
break;
}
}
Thoroar
10 years, 2 months ago