Hello,
I'm new to Qt, I started actually today with it, after I was making my gui (.ui file) in the editor, I came to the problem how can I show my second window, I found a solution with google, but now im walking in next problems, so I thought let's join a Qt forum and leave my win api forum
Anyways, this is my code.
DMain.cpp
#include "DMain.h"
#include "DBlock.h"
#include "ui_Dmain.h"
#include "ui_DBlock.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
BlockDialog* BlockDialogv = new BlockDialog(this);
if(!BlockDialogv->isVisible()) // this is not working
{
BlockDialogv->show();
BlockDialogv->activateWindow();
}
}
#include "DMain.h"
#include "DBlock.h"
#include "ui_Dmain.h"
#include "ui_DBlock.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
BlockDialog* BlockDialogv = new BlockDialog(this);
if(!BlockDialogv->isVisible()) // this is not working
{
BlockDialogv->show();
BlockDialogv->activateWindow();
}
}
To copy to clipboard, switch view to plain text mode
DBlock.cpp
#include "DBlock.h"
#include "ui_DBlock.h"
BlockDialog
::BlockDialog(QWidget *parent
) : ui(new Ui::BlockDialog)
{
ui->setupUi(this);
}
BlockDialog::~BlockDialog()
{
delete ui;
}
#include "DBlock.h"
#include "ui_DBlock.h"
BlockDialog::BlockDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::BlockDialog)
{
ui->setupUi(this);
}
BlockDialog::~BlockDialog()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
I'm trying to show a second dialog from my main, as you can see I tried to check if it allready existed, but off course this did not work, quite clearly if you look at the code, but I gave it a try. I want to make it so, that it can only open once and hide itselfs after someone closes it, I've to handle that in the BlockDialog class with a slot right?
Is this further all right coded?
Bookmarks