5 ms·
The thing I most remember about having to program with Qt was having to convert all my standard C++ types back and forth to QStrings and QLists and QFiles in or
by ryandrake 13y ago
The thing I most remember about having to program with Qt was having to convert all my standard C++ types back and forth to QStrings and QLists and QFiles in order to work with the library's APIs, and witnessing what happens when all the QThis and QThat objects start leaking over into your non-UI code if you're not careful.
I've always found it annoying to have to work with frameworks that invade your project with their own type defines, particularly when they are just parallel versions of types already in the language's standard library.
- AsymetricCom 13y agoTransform or overload them. Maybe someone should fork it to a standard-conforming version.
- adamnemecek 13y agoWhile I agree with your overall point, I think that in Qt most of the objects have a reason to exist. E.g. QString, unlike std::string has Unicode support.
- bcoates 13y agoNormally you'd either just use UTF-8 in a std::string or use std::wstring
- mpyne 13y agostd::string with UTF-8 is not a replacement for QString though. std::wstring is actually closer but then you're still going to have to do tons of conversions, and you still don't reach the feature scope of QString.
- sho_hn 13y agoThis is a completely fair point, however I think it's worth pointing out that especially considering the broad range of stuff Qt covers by itself, it's actually quite willing to intermingle with standard C++, and has continued to inch closer to standard C++. For example, Qt's containers work with std's algorithms (including the new C++11 iteration protocol) and Qt 5 introduced a new form of the signal/slot connect that's type-safe, based on templates and can connect to any callable (so including lambda, wheee ...), instead of being a macro that operates on normalized signature strings and annotated methods (while also still allowing you to ditch Qt signal/slots and use e.g. boost's if you prefer). And there's of course also a lot of historical reasons for the overall approach - when Qt started out, standard C++ was significantly weaker both in what the standard contained and how the standard was available. That's not to say I think Qt's mode of operating is obsolete, though; a lot of the value of Qt comes from good API hygiene (pleasant API design, consistent API pattern reuse), and I find that having my $usecase be met by a nice Qt-style API is generally a pleasant discovery.
- weland 13y agoI'm in the same camp. It makes porting difficult, indeed; but frankly, I'd use QThis and QThat over STL any day.
- drone 13y agoInteresting, I'm wondering how Qt types make porting more difficult? My experience has been that if I only used standard-C and Qt types, I had no issues in porting. A recent project I worked on only had a handful of platform checks (and all but one of them were in the project file), and compiled fine on all platforms. In fact, I developed it entirely on OSX first, and then simply adjusted the build to support the different OSes later, and didn't have a single problem. Mind you, I -only- used Qt standard libraries (except QExtSerialPort which was the best option for serial access at the time I started the project). I definitely agree with preferring Q-types to STL. Combined with Creator as an IDE, it's brain-dead simple and I spend my time on higher-level concerns. (FWIW, I wish Creator had more languages supported, I've never had such a wonderful experience in any other IDE. I want to shoot XCode every time I open it, mostly because Creator has spoiled me on how good auto-complete can be.)
- xarball 13y agoKDevelop won my heart over QtCreator a while back. Templates.
- weland 13y agoIf you already have a codebase that's littered with STL, you need to make a few changes here and there. I was thinking about "porting your codebase to Qt", which isn't quite a correct usage. Sorry, it was kind of late in the evening :(.
- xarball 13y agoExactly. Today I was astounded when I found out that passing NULL to std::string::operator=() results in a crash. Qt's QString and QByteArray classes run null checks on practically everything.
- auvrw 13y ago> The thing I most remember about having to program with Qt was having to convert all my standard C++ types back and forth to QStrings and QLists and QFiles in order to work with the library's APIs same think can happen with gtk or any framework (toolkit, actually, to be pedantic about it), and anyway, in an oo language especially, there are design patterns to cope with this.
- mpyne 13y agoWell, it did happen with GTK+. Go look at GLib (which underpins GTK+), it has its own string type, its own boolean type, even its own object-oriented programming scheme emulating Java-style OOP. Of course they have more of an excuse given that they wanted to stick with C instead of using C++ due to (at the time) poor language design and compiler support. But then again, that was Qt's excuse too! ;)
- cageface 13y agoI would pay cold hard cash for a modern UI toolkit that leveraged all the new stuff in C++11 and used OpenGL as a rendering backend. All standard containers and algorithms plus leveraging lambdas and C++11 concurrency tools. Most of the C++ libraries out there now have a ton of legacy cruft.
- andrewflnr 13y agoInteresting that you would prefer OpenGL and not native widgets/controls. Can you elaborate on why?
- cageface 13y agoMost of the apps I write have highly customized UI so I don't get that much benefit from native controls anyway. And having GL shaders available for any UI element would enable some pretty cool effects.
- pjmlp 13y agoDo you know about JUCE? http://www.juce.com/about-juce http://www.juce.com/about-juce
- cageface 13y agoWriting a desktop music app in JUCE right now, in fact. It's not bad but it shows it's age. A lot of it could be updated to use standard strings/collections/shared_ptr etc.
- sho_hn 13y agoQML sits on top of an OpenGL (ES)-powered scene graph in Qt 5.
- pjmlp 13y agoThere is a very important reason for it. Qt needed to be portable across several compilers and OSs, even before the ANSI C++ standard existed. Contrary to what many HN folks think, there are more compilers out there than just gcc, clang and visual c++.
- deleted 13y ago[deleted]