How to call ui->show(); from other file
-
int main(int argc, char *argv[])
{
QApplication a(argc, argv);QSurfaceFormat format; //antializing samples format.setSamples(16); TriangleWindow window; window.setFormat(format); window.resize(900, 700); window.setAnimating(true); window.show(); //gl MainWin m_win; m_win.show(); //ui timer_class tim; tim.start_play_timer(); return a.exec();
}
How to call ui->show(); from other file?
Cannot declare extern and place MainWin m_win before main() it crashes app.
Also would be good if QSurfaceFormat format; acessible by other files. -
I guess the
ui->show()
you're referring to is the one from the designer part of yourMainWin
class. Why don't you add a method inMainWin
which internally callsui->show()
? -
Can you please describe in more detail , my programming vocabulary not very good.
-
Well, your question is not so clear as well. I'll try again.
I guess the
ui
you're talking about is declared in the MainWin header fil e. Then what I told you is IF you need to be able to callui->show
, you could add a method inMainWin
class, which would internally callui->show
. However, I don't think this is usefull, as callingMainWin::show()
callsshow
for theui
component.I have no clue about which
QSurfaceFormat
instance you're talking about. I don't have any crystal ball, therefore it's hard to tell. -
Very sorry, i was not aware that you are not having big crystal ball.
Would like to be able to call TriangleWindow and mainwin from eachother to respawn closed window. -
@Q139
Hi your idea with extern should be able to work.
Just use pointers and it will work.in "TriangleWindow.h"
have
extern TriangleWindow *MyTW;
and have it defined in the .cppand then in main
do
MyTW=new TriangleWindow();
Then in other file , say mainwindow you can include
TriangleWindow .h and have access via
MYTW;
This is of course global variables and might
not be the most elegant way of handling it.regarding
QSurfaceFormat format;
This only lives in main and you must move it as only main can see it.