Cannot press QPushButton in a simple program

Posted by shadyabhi on Stack Overflow See other posts from Stack Overflow or by shadyabhi
Published on 2010-05-27T12:29:52Z Indexed on 2010/05/27 12:31 UTC
Read the original article Hit count: 154

Filed under:
|
|
|

Basically, I want a simple pushButton with a colorful text which when pressed exits the application.

Why cant I press PushButton in this simple program. I am using QT 4.6 on Arch x86_64.

#include <QtGui/QApplication>
#include <QLabel>
#include <QPushButton>
#include<QtGui>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QMainWindow *Main=new QMainWindow;

    QPushButton *button = new QPushButton(Main);
    QLabel *label = new QLabel(Main);
    label->setText("<h2><i>Hello</i> ""<font color=red>Qt!</font></h2>");
    label->setVisible(true);
    QObject::connect(button, SIGNAL(clicked()),label, SLOT(clear()));
    label->setAlignment(Qt::AlignCenter|Qt::AlignVCenter);
    label->setWindowTitle("HelloWorld Test Program");
    Main->show();
    return a.exec();
}

© Stack Overflow or respective owner

Related posts about c++

Related posts about linux