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
#include "matematica.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
Matematica w;
w.show();
return a.exec();
}
#include "matematica.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Matematica w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
matematica.h
#ifndef MATEMATICA_H
#define MATEMATICA_H
#include <QtGui/QMainWindow>
#include "ui_matematica.h"
#include <QMessageBox>
#include "Grafico2D_Dlg.h"
{
Q_OBJECT
public:
~Matematica();
private:
Ui::MatematicaClass ui;
private slots:
void newFile();
void Graf2D();
private:
Grafico2D_Dlg *gr2D;
private:
void createActions();
};
#endif // MATEMATICA_H
#ifndef MATEMATICA_H
#define MATEMATICA_H
#include <QtGui/QMainWindow>
#include "ui_matematica.h"
#include <QMessageBox>
#include "Grafico2D_Dlg.h"
class Matematica : public QMainWindow
{
Q_OBJECT
public:
Matematica(QWidget *parent = 0);
~Matematica();
private:
Ui::MatematicaClass ui;
private slots:
void newFile();
void Graf2D();
private:
Grafico2D_Dlg *gr2D;
private:
void createActions();
QAction *newAction;
QAction *graf2DAction;
};
#endif // MATEMATICA_H
To copy to clipboard, switch view to plain text mode
matematica.cpp
#include "matematica.h"
Matematica
::Matematica(QWidget *parent
){
createActions();
ui.setupUi(this);
}
Matematica::~Matematica()
{
}
void Matematica::createActions()
{
newAction
= new QAction(tr
("&New"),
this);
newAction
->setIcon
(QIcon(":/images/new.png"));
newAction->setStatusTip(tr("Create a new file"));
connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
/*graf2DAction = new QAction(tr("&Gráfico 2D"), this);
newAction->setIcon(QIcon(":/images/graf2d.png"));
newAction->setShortcut(QKeySequence::New);
newAction->setStatusTip(tr("Create a new graph 2D"));
connect(graf2DAction, SIGNAL(triggered()), this, SLOT(Graf2D()));
*/
graf2DAction
= new QAction(QIcon(":/images/graf2d.png"),tr
("Grafico 2D"),
this);
graf2DAction->setStatusTip(tr("Create a new graph 2D"));
connect(graf2DAction, SIGNAL(triggered()),this, SLOT(Graf2D()));
}
void Matematica::newFile()
{
tr("<h2>New File</h2>"));
}
void Matematica::Graf2D()
{
tr("<h2>Grafico 2D</h2>"));
}
#include "matematica.h"
Matematica::Matematica(QWidget *parent)
: QMainWindow(parent)
{
createActions();
ui.setupUi(this);
}
Matematica::~Matematica()
{
}
void Matematica::createActions()
{
newAction = new QAction(tr("&New"), this);
newAction->setIcon(QIcon(":/images/new.png"));
newAction->setShortcut(QKeySequence::New);
newAction->setStatusTip(tr("Create a new file"));
connect(newAction, SIGNAL(triggered()), this, SLOT(newFile()));
/*graf2DAction = new QAction(tr("&Gráfico 2D"), this);
newAction->setIcon(QIcon(":/images/graf2d.png"));
newAction->setShortcut(QKeySequence::New);
newAction->setStatusTip(tr("Create a new graph 2D"));
connect(graf2DAction, SIGNAL(triggered()), this, SLOT(Graf2D()));
*/
graf2DAction = new QAction(QIcon(":/images/graf2d.png"),tr("Grafico 2D"),this);
graf2DAction->setStatusTip(tr("Create a new graph 2D"));
connect(graf2DAction, SIGNAL(triggered()),this, SLOT(Graf2D()));
}
void Matematica::newFile()
{
QMessageBox::about(this, tr("New File"),
tr("<h2>New File</h2>"));
}
void Matematica::Graf2D()
{
QMessageBox::about(this, tr("Grafico 2D"),
tr("<h2>Grafico 2D</h2>"));
}
To copy to clipboard, switch view to plain text mode
Bookmarks