This does not work:
void MainWindow::on_left_win_clicked()
{
Dialog *dialog1 = new Dialog(this);
dialog1->show();
return;
}
However this does:
void MainWindow::on_left_win_clicked()
{
QDialog *dialog1 = new QDialog(this);
dialog1->show();
return;
}
I just used the standard Qt Designer Form Class -> Dialog with Buttons Bottom
EDIT: added dialog.h and dialog.cpp
dialog.h This is just the standard dialog.h no changes that was created for me in the designer window.
#ifndef DIALOG_H
#define DIALOG_H
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
private:
Ui::Dialog *ui;
};
#endif // DIALOG_H
dialog.cpp. Only part I added here was the setWindowFlags based on a suggestion in another thread (didn't help).
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent)
: QDialog(parent), ui(new Ui::Dialog)
{
ui->setupUi(this);
setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::Dialog);
}
Dialog::~Dialog()
{
delete ui;
}