Hello, I'm not sure this question belongs in this ng, sorry if it doesn't.
I like to learn a bit of C++ with QT4, not using the designer but writing
all code myself. But I came to a problem I can't solve, in fact I have no
idea whatsoever. I made a 'connect' with SIGNAL and SLOT, but it fails to
work.
Here's a bit of code:
************************* code ************
#include <QtGui>
#include "qnews.h"
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
setFixedSize(600, 300);
setWindowTitle("Vito's QNews");
QPushButton *postButton = new QPushButton(tr("Post"), this);
postButton->setGeometry(10, 260, 75, 30);
//not relevant code removed here ...
// here's the signal/slot command
connect(postButton, SIGNAL(clicked()), this, SLOT(checkFile()));
}
// here's the function that must be executed - showing a msgBox
void MyWidget::checkFile()
{
QMessageBox msgBox;
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
switch (msgBox.exec()) {
case QMessageBox::Yes:
// yes was clicked
break;
case QMessageBox::No:
// no was clicked
break;
default:
// should never be reached
break;
}
}
********* end code **************
But when I click the postButton, nothing happens ....
What's wrong in this code? All info very welcome.
BTW: I'm not English, sometimes understanding English docs is not easy
for me. But I do my best :-)
Vito


|