Effect of QApplication for a console application.
-
Hello,
I have a purely console application, that uses QCoreApplication. But i need to use a library, which uses QTreeWidget as a data structure for one of its results. There is absolutely no visual component displayed, but to use QTreeWidget, qt tells me to make a gui application, so I need to change the application to QApplication. Searched the internet but could not find a posting about the performance issues this switch will bring. Apart from the initialization, is there too much overhead introduced for using QApplication instead of QCoreApplication?
-
The main issue, I think, is that you will need a running X server if you run your application on *nix. I don't think there will be much of a performance hit, unless your app is intended to perform a very short task often, and is continuously started and stopped for that purpose. However, the best way to tell is to simply test it on your platform.
-
thanks for the reply. You just made me realize that converting to QApplication while giving the GUIenable parameter as false in constructor, was not enought to create a QTreeWidget. I have to create a gui application, and as you said, on a unix system, it asks for an X11 server on startup, which i dont have. So performance issue is not a concern any more. Will have to change the library to return a non gui class as result.
-
Might be a good idea anyway. Using a QTreeWidget as a data structure only doesn't sound like a good idea.
If you are looking for a tree data structure, then perhaps look into "tree.hh":http://tree.phi-sci.com/. I use it, and it works well. Even wrote a class to make such a tree work as the data source for a QAbstractItemModel.
-
[quote author="ZapB" date="1300281778"]You should be able to get at the QTreeWidget's internal model via QAbstractItemView::model().[/quote]
Since you can not create a QTreeWidget in a non-gui application, I see no way of getting to the internal model of one anyway then? Also, I am not sure you can actually use it, since the QTreeWidgetItems would expect a working QTreeWidget to be present.You might be able to use a QStandardItemModel for the same purpose though. Still, personally, I would avoid using it, especially if you don't intent to use it with a view.
-
If you have a non gui app, why do you return the data as QTreeWidget? QTreeWidget is a UI class, not a data container.
It makes much more sense to return a data structure, which can then be used by a model to be displayed in a tree, than returning a UI class for that.