Calling the dialog checkbox from mainwindow
-
You have declared Dialog *tt in tha MainWindow.h.
Then in the mainWindow.cpp
jus the following is needed
@
tt = new Dialog(this);
@
right???is the following line needed in the dialog.h??
@
Ui::MainWindow *uu;
@ -
i am getting an error in the mainwindow error: 'class Dialog' has no member named 'checkBox'. the tt = new Dialog(this); line is for dialog methods. i need it for dialog widgets in the mainwindow.cpp file.
-
Im not an expert :)
u have a checkbox in your dialog.h. and it is made in the designer??
You want to jus show that check box in the mainWindow??
Am i right???
-
yes. i want to call the dialog checkbox from mainwindow
-
This displays the check box.
The following is written in the constructor of MainWindow.cpp@
ui->setupUi(this);
Dialog *d= new Dialog();
d->show();
setCentralWidget(d);
@alfah
-
not working. please verify.
-
it is working on my device. Remember i have called the dialog class/form from the mainwindow ,if thats wat you want
Dialog.cpp
@
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
setLayout(ui->verticalLayout);}
@MainWindow.cpp
@
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
Dialog *d= new Dialog();
d->show();
setCentralWidget(d);}
@alfah
-
o yes. it worked.
-
:) ok, [Solved] i guess
-
not yet. the setCentralWidget(tt); hides the widgets on my mainwindow
-
ofcourse it will!! because what you have done is callin a form from the MainWindow, so it will be shown over the MainWindow. You din tell me you had widgets on the MainWindow!
-
is there another way around this?
-
would you explain a bit on what is there on the mainWindow and what exactly you want to do ?How do you want to display??
alfah
-
I have a lot of widgets on the mainwindow. when the program loads, it loads the mainwindow and then the dialog. the dialog loaded is not in focus so i need to load the dialog from the mainwindow and then check if the dialog is loaded. if the dialog is not loaded then i need to write some code in the mainwindow.
i need to call the dialog checkbox from the mainwindow to determine if the dialog is displayed. if the dialog is not displayed then i can write my code in the dialog.cpp file.
-
loaded as in displayed?
-
yes that's correct