#include <Qpushbutton>
#include <QApplication>
#include <Qwidget>
#include <QTextCodec>
#include <QVBoxLayout>
#include <QFont>
#include <QLabel>
class myclass : public QWidget
{
public:
myclass();
~myclass();
private:
QPushButton * pl;
QLabel * LB;
};
myclass::myclass()
{
this->setGeometry(100,150,300,200);
pl = new QPushButton(QObject::tr("我来了"),this);
pl->setGeometry(20,20,160,70);
pl->setFont(QFont("Courier",19,QFont::Light,true));
connect(pl,SIGNAL(clicked()),this,SLOT(quit())); //这里本来是想关闭窗口的.可是关闭不了.
LB = new QLabel(this);
LB->setText(QObject::tr("我们都是中\n办"));
LB->setGeometry(20,90,100,100);
}
myclass::~myclass()
{
delete pl;
delete LB;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030"));
myclass * windows = new myclass;
windows->show();
return a.exec();
}
求高手们帮忙,这个安钮如何才能关闭窗口.