PDA

View Full Version : Existing Window Call



hasnatzaidi
30th September 2009, 18:03
hi , I posted thread earlier regarding this problem but not solved.
Here Following code are call UI file in Main Project


void MainWindow::on_btn_screate_clicked()
{
// sessiondetail.ui is another UI file in same project
Ui::sessiondetail ui;
QMainWindow *sessiondetail = new QMainWindow;
ui.setupUi(QMainWindow *sessiondetail);

}


And its output error is

mainwindow.cpp:462: error: expected primary-expression before '*' token

As a result which i want the sessiondetail.ui file must be displayed when click on button.
Can anyOne Plz Slove this problem
thanks to every one

Regards, Raza

wysota
30th September 2009, 18:18
The code is syntactically incorrect. The line "6" should read "ui.setupUi(sessiondetail);".

hasnatzaidi
30th September 2009, 18:56
thanks Wysota, for doing this it can't generate error
but it also can't call UI file which i want, when click on button

wysota
30th September 2009, 19:25
Sure it can. But it will go out of scope immediately. Look at your code again - you created an object local to the function and can't expect it to last beneath the function.

hasnatzaidi
30th September 2009, 19:38
thanks
it done with this code

void MainWindow::on_btn_screate_clicked()
{

Ui::sessiondetail ui;
QMainWindow *sessiondetail = new QMainWindow;
ui.setupUi(sessiondetail);
sessiondetail->show();

}
but it display sessiondetail.ui file 2 times,
what reason behind it

wysota
30th September 2009, 20:02
Come on man.... Learn a bit of C++ before taking on Qt...