Posts

Showing posts with the label Qt

Console/Terminal Widget For Qt?

Answer : QConsole used to do something like that. (Not sure the project is active anymore, but you might want to have a look). Found some decent source code here. Very basic functionality, but I've been adding to it some and I think it has promise to do what I need it to. NOTE: I have only tested this code in Win32. Here is a link to my new question concerning this code.

Convert Std::string To QString

Answer : QString::fromStdString(content) is better since it is more robust. Also note, that if std::string is encoded in UTF-8, then it should give exactly the same result as QString::fromUtf8(content.data(), int(content.size())) . There's a QString function called fromUtf8 that takes a const char* : QString str = QString::fromUtf8(content.c_str()); Usually, the best way of doing the conversion is using the method fromUtf8, but the problem is when you have strings locale-dependent. In these cases, it's preferable to use fromLocal8Bit. Example: std::string str = "ëxample"; QString qs = QString::fromLocal8Bit(str.c_str());