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?!
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?!