I have a very simple application, a main window with a toolbar with two buttons.
I want to click a button and make a dialog or a messagebox appear, but nothing happens when I click.
What am I doing wrong?


This is my code

main.cpp

Qt Code:
  1. #include "matematica.h"
  2.  
  3. #include <QtGui>
  4. #include <QApplication>
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8. QApplication a(argc, argv);
  9. Matematica w;
  10. w.show();
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 


matematica.h

Qt Code:
  1. #ifndef MATEMATICA_H
  2. #define MATEMATICA_H
  3.  
  4. #include <QtGui/QMainWindow>
  5. #include "ui_matematica.h"
  6. #include <QMessageBox>
  7. #include "Grafico2D_Dlg.h"
  8.  
  9.  
  10. class Matematica : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. Matematica(QWidget *parent = 0);
  16. ~Matematica();
  17.  
  18. private:
  19. Ui::MatematicaClass ui;
  20.  
  21. private slots:
  22. void newFile();
  23. void Graf2D();
  24.  
  25. private:
  26. Grafico2D_Dlg *gr2D;
  27.  
  28. private:
  29. void createActions();
  30.  
  31. QAction *newAction;
  32. QAction *graf2DAction;
  33.  
  34.  
  35.  
  36. };
  37.  
  38. #endif // MATEMATICA_H
To copy to clipboard, switch view to plain text mode 


matematica.cpp

Qt Code:
  1. #include "matematica.h"
  2.  
  3. Matematica::Matematica(QWidget *parent)
  4. : QMainWindow(parent)
  5. {
  6. createActions();
  7. ui.setupUi(this);
  8.  
  9. }
  10.  
  11. Matematica::~Matematica()
  12. {
  13.  
  14. }
  15.  
  16. void Matematica::createActions()
  17. {
  18.  
  19. newAction = new QAction(tr("&New"), this);
  20. newAction->setIcon(QIcon(":/images/new.png"));
  21. newAction->setShortcut(QKeySequence::New);
  22. newAction->setStatusTip(tr("Create a new file"));
  23. connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
  24.  
  25.  
  26.  
  27. /*graf2DAction = new QAction(tr("&Gráfico 2D"), this);
  28. newAction->setIcon(QIcon(":/images/graf2d.png"));
  29. newAction->setShortcut(QKeySequence::New);
  30. newAction->setStatusTip(tr("Create a new graph 2D"));
  31. connect(graf2DAction, SIGNAL(triggered()), this, SLOT(Graf2D()));
  32. */
  33.  
  34. graf2DAction = new QAction(QIcon(":/images/graf2d.png"),tr("Grafico 2D"),this);
  35. graf2DAction->setStatusTip(tr("Create a new graph 2D"));
  36. connect(graf2DAction, SIGNAL(triggered()),this, SLOT(Graf2D()));
  37.  
  38.  
  39. }
  40.  
  41.  
  42. void Matematica::newFile()
  43. {
  44.  
  45. QMessageBox::about(this, tr("New File"),
  46. tr("<h2>New File</h2>"));
  47. }
  48.  
  49. void Matematica::Graf2D()
  50. {
  51. QMessageBox::about(this, tr("Grafico 2D"),
  52. tr("<h2>Grafico 2D</h2>"));
  53. }
To copy to clipboard, switch view to plain text mode