LoveUnix » 编程开发 & Rational » 简单的Qt程序,不知道错哪儿了?
让LU留住您的每

一天 让LU博客留住您的每一天
2006-5-22 02:29 style1987
简单的Qt程序,不知道错哪儿了?

#include <qapplication.h>
#include <qpushbutton.h>

class myWidget:public QWidget
{
        Q_OBJECT
        public:
                myWidget(QWidget *parent = 0, const char *name = 0);
        public slots:
                void shutDown();
        private:
                QPushButton *exit;
};

myWidget::myWidget(QWidget *parent, const char *name):QWidget(parent, name)
{
        setMinimumSize(120, 180);
        setMaximumSize(120, 180);
        exit = new QPushButton("ShutDown!",this);
        connect(exit,SIGNAL(clicked()),this,SLOT(shutDown()));
}

void myWidget::shutDown()
{
        system("halt");
}

int main(int argc, char **argv)
{
        QApplication app(argc, argv);
        myWidget *w = new myWidget();
        w->show();
        app.exec();
}

//有问题吗?一个简单的按钮,按下就shutdown computer.

页: [1]


Powered by Discuz! Archiver 5.5.0  © 2001-2006 Comsenz Inc.