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 your
MainWinclass. Why don't you add a method in
MainWinwhich internally calls
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
uiyou're talking about is declared in the MainWin header fil e. Then what I told you is IF you need to be able to call
ui->show, you could add a method in
MainWinclass, which would internally call
ui->show. However, I don't think this is usefull, as calling
I have no clue about which
QSurfaceFormatinstance 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.
Hi your idea with extern should be able to work.
Just use pointers and it will work.
extern TriangleWindow *MyTW;
and have it defined in the .cpp
and then in main
Then in other file , say mainwindow you can include
TriangleWindow .h and have access via
This is of course global variables and might
not be the most elegant way of handling it.
This only lives in main and you must move it as only main can see it.