Lycus HackerEmo
28th December 2009, 03:44
I am creating a small program that contains 2 QPusButon, the button "Hola" serves as clicking on the button it should display the message "Hola Mundo", the other button "Salir" what you should do is that when clicked must close the program, but does not work.
#include <QtGui>
#include "holamensaje.h"
holamensaje::holamensaje(QWidget *parent)
: QWidget(parent)
{
holabutton = new QPushButton("Hola");
salirbutton = new QPushButton("Salir");
connect(holabutton, SIGNAL(clicked()),this, SLOT(hola()));
QObject::connect(salirbutton, SIGNAL(clicked()),this, SLOT(quit()));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(holabutton);
layout->addWidget(salirbutton);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(holabutton, 0, 0);
mainLayout->addWidget(salirbutton, 0, 1);
setLayout(layout);
setWindowTitle("Hola Mensaje");
resize(250, 100);
}
void holamensaje::hola()
{
QMessageBox msgBox;
msgBox.setText("Hola Mundo!!!");
msgBox.exec();
}
I'm newbie. sorry my English and to use the google translator
#include <QtGui>
#include "holamensaje.h"
holamensaje::holamensaje(QWidget *parent)
: QWidget(parent)
{
holabutton = new QPushButton("Hola");
salirbutton = new QPushButton("Salir");
connect(holabutton, SIGNAL(clicked()),this, SLOT(hola()));
QObject::connect(salirbutton, SIGNAL(clicked()),this, SLOT(quit()));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(holabutton);
layout->addWidget(salirbutton);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(holabutton, 0, 0);
mainLayout->addWidget(salirbutton, 0, 1);
setLayout(layout);
setWindowTitle("Hola Mensaje");
resize(250, 100);
}
void holamensaje::hola()
{
QMessageBox msgBox;
msgBox.setText("Hola Mundo!!!");
msgBox.exec();
}
I'm newbie. sorry my English and to use the google translator