Hi there,
I'm writing some application based on Qt and C++ and I've reached the problem. How to display window via clicking, triggering, etc. I wrote some code:
//----------------------------
// THIS IS IN mainwindow.h
//----------------------------
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui
{
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void DisplayAuthors();
};
#endif // MAINWINDOW_H
//----------------------------
// THIS IS IN mainwindow.cpp
//----------------------------
#include "mainwindow.h"
#include "authorswindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->actionAutorzy, SIGNAL(triggered()), this, SLOT(DisplayAuthors()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::DisplayAuthors()
{
AuthorsWindow authors;
authors.show();
}
The AuthorsWindow is simple window with labels and one image (nothing more). As you can see I'm trying to display window from choosing menu item and clicking it. The signal and slot are both working correctly, becouse (this.close();) works on DisplayAuthors(). The point is - window does not apper. What's wrong with my code?