Hello you all!
I'm a newbie in Qt programming so my question will probably seem a stupid question but all guides I read didn't help me...
I'm developing a C/C++ program in Win Vista & Qt Creator IDE with the Qt framework. It is a Qt GUI Application (the one you can create by clicking New -> project)
I'd like to connect the event of clicking a PushButton with a function I wrote earlier. Here is the code of my mainwindow.cpp file:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include<QMessageBox>
{
public slots:
void buttonClicked()
{
}
};
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
PB->setText("Button text");
act a;
connect(PB, SIGNAL(clicked()), &a,SLOT(buttonClicked()));
PB->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include<QMessageBox>
class act: public QObject
{
public slots:
void buttonClicked()
{
QMessageBox("Title","Msg",QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
}
};
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QPushButton *PB= new QPushButton(this);
PB->setText("Button text");
act a;
connect(PB, SIGNAL(clicked()), &a,SLOT(buttonClicked()));
PB->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
It is executed correctly but when I push the button the message doesn't show!
What could be the problem?
Thanks a lot, harmodrew
Bookmarks