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:
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QPushButton>
  4. #include<QMessageBox>
  5. class act: public QObject
  6. {
  7. public slots:
  8. void buttonClicked()
  9. {
  10. QMessageBox("Title","Msg",QMessageBox::NoIcon,QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
  11. }
  12. };
  13. MainWindow::MainWindow(QWidget *parent) :
  14. QMainWindow(parent),
  15. ui(new Ui::MainWindow)
  16. {
  17. QPushButton *PB= new QPushButton(this);
  18. PB->setText("Button text");
  19. act a;
  20. connect(PB, SIGNAL(clicked()), &a,SLOT(buttonClicked()));
  21. PB->show();
  22. }
  23. MainWindow::~MainWindow()
  24. {
  25. delete ui;
  26. }
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