PDA

View Full Version : Problem getting some Windows and Dialogs to show.



billw
19th November 2010, 15:37
Specifically I have a simply application window that I created using QtDesigner, which worked fine on 4.5.1 but now behaves strangely on 4.7.1: I have to create and then show it twice, it will only show the second time it is created:


QApplication a(argc, argv);

{
WindowGUIClass w;

w.show();
w.setFocus(); // <-- this one never appears (even without the enclosing scope causing it to get destroyed)
}

WindowGUIClass w2;

w2.show(); // <-- now it will actually appear
w2.setFocus();

return a.exec();


So I hacked my way around that problem after spending a couple of hours trying to work out what the problem is (comparing project settings to a newly created Qt app project, removing ALL extraneous code from the initialization, making it identical to the default generated Qt app).
The only slightly non-standard thing that is in effect when running this program is that it is being spawned by another process rather than started by the user.
Now I have run into another problem: QMessageBox will not display when I use the following code:



inline void show_error(const char* err, const char* title = "Error!")
{
QMessageBox::critical(NULL, title, err); // <-- nothing appears...
}


I am using Windows XP 32bit and Qt 4.7.1. My projects were created in 4.5.1, using Visual Studio 2005, and the Qt VS plugin. I am now using VS2008 with the Qt VS plugin.

So, I ask, what is the problem here? Are there any commonly known problems with getting windows to show? I have tried stepping though the code that is supposed to show the window, but to no avail...

/edit So I managed to fix the QMessageBox not displaying by giving a parent QWidget rather than NULL. I also noticed that when the parent IS NULL, the setVisible(true) call buried in the critical() function generates a Windows error sound... Qt bug?!

franz
22nd November 2010, 12:51
No issues that I know of. I'm using 4.7.1 on a rather complex program and I don't need any hacks to get windows displayed. Could you post a full example of the problem in a zip/tar? It'd probably generate more responses.