PDA

View Full Version : How to separate program logic from GUI



radex99
19th September 2010, 18:53
Hello I`m trying to separate programm logic from the GUI, I want to have multiwindowed application with logi placed in my class not MainWindow like it is in most example cases. And I want to start my windows, give them a pointers to Data, they would fill the data, close and next window would be run. What to do in such situation try to override the qapplication(If yes where should i put my logic in which QApplication method) or it can be done by "just like that"


QApplication a(argc,argv);
MainWindow *w = new MainWindow();
w->show();
a->exec();
//Here to place the loop of comunication beetwen this and windows
//Main loop of gui communication with logic
//Start windows, close windows, switch results, make actions
//MAIN LOOP
return 0;

if this loop is posiblle to create pls tell my how. Should i make some signals to comunicate with my window or in other way.I achiewed that signals are protected by default so is it possible or there is a better way to sepate the logic from window pls help, give me some clues, or examples.

Zlatomir
19th September 2010, 19:14
You don't need another loop (you already have one)

Just code your classes that will contain and work the with data you need.

Also you can take a look at the Model View Programming (http://doc.qt.nokia.com/4.6/model-view-programming.html), it may be what you are looking for.