1
I am 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 about doing one QDialog
, but depending on it would get complicated to edit some things and put images, for example. So I created ui'which will be called by these actions triggered by the signal triggered
.
But I can’t get the window call to open when the signal is triggered.
I imported the library .h
of the window I want to call, in case the aboutMain
. I created an object of hers (a new window) and now I want to show.
That’s the way it is?
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();
}
So, and a menu bar action, so when I create an item there it already creates a direct action, I only define after which is the signal. In this case I chose Triggered, which is the most click-like action there is. When I build, other features work, but when I click on this item, nothing happens. I right-clicked on the item, Go To Slot, Triggered action. It is declared as Private Slot.
– Lays Rodrigues
Edited.
– Lays Rodrigues
This form of statement is deprecated in Qt 5.2. it is in that direct form that I actually made...
– Lays Rodrigues
Sorry Lays, I use Qt since version 5.0 and did not know this, could you provide me the source of such information? As far as I know these "writing/running styles" are C++ and not QT and maybe it changes according to the C++ version and not QT, for example from c++89 to C++11 there were changes. I would be grateful if you could provide me with the link of such information. Thank you.
– Guilherme Nascimento
Well I based myself on the main generated by Qt itself. For there it shows how it calls the Main window for example. I will put the example of code up there.
– Lays Rodrigues
I cannot do Signal in hand, because the pandora.ui does not recognize the object aboutBrPrint. And this Signal is generated automatically when I create the item in the menu bar. I can’t get another one to over-write it, otherwise I would have solved the case, because I did it with another question of windows. I cannot create a separate connect. = / Pq in this case the action is triggered by a menu bar option, not a push buttom.
– Lays Rodrigues