PDA

View Full Version : Datastructures: QT vs STD



Michiel
17th March 2006, 14:31
When you use data-structures (strings, lists, sets) in your qt project code, do you use the std ones, or the qt ones?

How do they compare size/speed wise? And when, for example, I want to use an std::string in some existing widgets, will they need be converted to a QString (automatically or otherwise) first?

I'm trying to make this decision. I'm probably going to use std classes, though, since I'd like to make a command-line version of the same application, and I'd like to avoid using any QT libraries in that.

wysota
17th March 2006, 15:34
When you use data-structures (strings, lists, sets) in your qt project code, do you use the std ones, or the qt ones?

In most cases Qt containers are compatible with STL ones, so it doesn't matter which ones you use. For some cases Qt classes are faster or more adjusted to cooperating with other Qt classes. In some cases you have to use Qt containers.


How do they compare size/speed wise?

Qt classes are generally "not slower" than STL ones, but they have more capabilities when it comes to cooperating with Qt.

[qutote] And when, for example, I want to use an std::string in some existing widgets, will they need be converted to a QString (automatically or otherwise) first?[/quote]
In most cases it'll get automatically converted. But the main difference is that QString uses unicode internally, whereas std::string doesn't. It has more features than std::string and is probably a bit slower.



I'm trying to make this decision. I'm probably going to use std classes, though, since I'd like to make a command-line version of the same application, and I'd like to avoid using any QT libraries in that.

You can make a command-line version of the application using Qt too. You can even have the same binary for GUI and console versions.

Michiel
17th March 2006, 16:18
You can make a command-line version of the application using Qt too. You can even have the same binary for GUI and console versions.

I know I could. But won't compiling with QT in the mix mean a lot of overhead? I've looked at that QT inheritance tree. :)

wysota
17th March 2006, 16:19
No, it won't. Why would it? Just use QtCore only if you want an extra-light version.