I'm developing a solution in qt5.4.2, in my menu bar, when clicking an option, a new window should open with that information.
I was thinking of doing a QDialog
, but depending on it would be complicated to edit some things and put images, for example. Then I created ui 's that will be called by these actions triggered by the triggered
sign.
But I can not get the calling window open when the signal is triggered.
I imported the .h
library of the window I want to call, in this case the aboutMain
. I created an object from it (a new window) and now I want to show it.
Is this the way?
brprint.h - > .h main
#include <QMainWindow>
#include "loading.h"
namespace Ui {
class BrPrint3D;
}
class BrPrint3D : public QMainWindow
{
Q_OBJECT
public:
explicit BrPrint3D(QWidget *parent = 0);
~BrPrint3D();
void init();
private slots:
void on_actionSobre_BrPrint3D_triggered();
private:
Ui::BrPrint3D *ui;
};
brprint3d.cpp
#include "brprint3d.h"
#include "ui_Pandora.h"
#include "aboutbrprint.h"
#include <stdio.h>
//Sobre->Sobre o BrPrint3D
void BrPrint3D::on_actionSobre_BrPrint3D_triggered()
{
//Chamar Janela Sobre o BrPrint
aboutBrPrint window;
window.show();
}
aboutBrPrint.h
#include <QWidget>
namespace Ui {
class aboutBrPrint;
}
class aboutBrPrint : public QWidget
{
Q_OBJECT
public:
explicit aboutBrPrint(QWidget *parent = 0);
~aboutBrPrint();
private:
Ui::aboutBrPrint *ui;
};
Main
#include "brprint3d.h"
#include <QApplication>
#include "loading.h"
#include <QTranslator>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
BrPrint3D w;
w.show();
w.init();
return app.exec();
}