-
Global Qt Objects
Is there any danger in having a global object that uses Qt classes? Is there anything in the Qt framework that needs to be initialized before using classes such as QString or QHash?
Some customers have crashes at startup before entering main() where the QApplication object is created. For those that it happens to, it happens every time. Sending them a rebuild of the same code seems to fix the problem. Very strange. For other people it seems to never happen.
I already understand the risks and benefits of using global objects in general. I'm just wondering if Qt classes can be used in global objects since they are instantiated before the QApplication is created.
-
Re: Global Qt Objects
I am not aware of any restrictions regarding global Qt objects. I have successfully used a QFile global object w/o any problems. As I'm sure you are aware, you should synchronize access to global objects.
Perhaps other may know if there are restrictions with QString or QHash, etc.
-
Re: Global Qt Objects
As long as you are not using anything that requires an instance of QApplication then you are ok. Widgets are not ok, pixmaps are not ok and anything that uses plugins is not ok. QHash and QString are definitely ok :)
-
Re: Global Qt Objects
Ok, thanks for weighing in everyone. That's what I could determine too since Qt is meant to be a library and not just for GUI application. I'll post here if I learn anything new.