在下面的代碼中,我創建一個窗口,調用window.show()
,但該窗口不會顯示,直到調用window->iterateSolution()
之後。幾乎就好像,app.exec()
是顯示窗口的函數。我對Qt非常陌生,所以我不知道發生了什麼。Qt:mainWindow-> show();不顯示主窗口
#include <QtGui/QApplication>
#include <mainWindow.h>
#include <Cube.h>
mainWindow * newWindow;
int main(int argc, char *argv[]) {
// initialize resources, if needed
// Q_INIT_RESOURCE(resfile);
QApplication app(argc, argv);
newWindow = new mainWindow;
newWindow->show();
QString initialState = "YWOBYYBYYGRRGRRBWWYOOYGGRGGBBGYOOYOOWRRBBRBBWGOOGWWRWW";
/* Construct cube, set state, and solve */
Cube * cube = new Cube(initialState);
QString solution = cube->solve();
delete cube;
newWindow->iterateSolution(solution);
// create and show your widgets here
return app.exec();
}
好的,但我想在哪裏執行我的功能? – dfetter88 2010-12-03 23:07:50