Hot answers tagged

173

I don't really intend this to be a bashing answer, but these are the reasons I do not personally use Qt. There are plenty of good things to say about it -- namely that the API works most of the time, and that it does seamlessly bridge platforms. But I do not use Qt, because: In some cases, it just doesn't look like native programs look. Designing a single ...


114

As people say, each tool fits to each problem and situation... But if you're C++ programmer, Qt is your framework. No rival. We develop a complex medical imaging commercial application, and Qt holds on. I don't say that the 'cons' that people say about it are false, but I have the feeling that they don't have tried Qt for a long time (its continously ...


70

A "raw" pointer is unmanaged. That is, the following line: SomeKindOfObject *someKindOfObject = new SomeKindOfObject(); ... will leak memory if an accompanying delete is not executed at the proper time. auto_ptr In order to minimize these cases, std::auto_ptr<> was introduced. Due to the limitations of C++ prior to the 2011 standard, however, it's ...


36

If you re-write & re-design from scratch, you're going to have two MASSIVE problems: You don't have a spec. You might think you have a spec, but it turns out that the REAL spec is the old code. So you're going to have to dig into it to figure out what it really does, just so you know what to make the new system do. You'll have a long period (looking at ...


35

Of all the things I don't like about Qt, the fact that it doesn't play well with templates bugs me the most. You can't do this: template < typename T > struct templated_widget : QWidget { Q_OBJECT; public signals: void something_happened(T); }; It also doesn't play well with the preprocessor. You can't do this: #define CREATE_WIDGET(name,type)...


28

One reason to not use Qt is that if you only write for one architecture, such as Windows, you may want to use C#/.NET (or Cocoa on Mac) because they will invariably be able to take advantage of the latest bells-and-whistles of the OS. If you are writing cross-platform apps, then you may already be heavily vested in another technology such as Java (i.e. you ...


26

Some of it is licensing. See https://en.wikipedia.org/wiki/Qt_(software)#Licensing for some of the licensing history. Until 2000, people who cared strongly about open source, did not use Qt. Period. (This was, in fact, the original motivation for the development of Gnome.) Until 2005, people who wanted to be able to release free software for Windows did ...


18

The most damage you will be doing to yourself, if you want to put it that way, is that you will not be learning to use the standard C++ data structures, iterators, algorithms and strings at all. Qt has libraries of its own for all those purposes, and you are all but forced to use them instead of standard C++ entities because Qt APIs only accept data ...


15

I wouldn't refrain from using Qt just for those reasons. You are not required to use all of Qt's utility classes; for the ones that replace the STL, you'll at most be forced to use QString and, possibly, QStringList. Also, there's usually much more to a program than the GUI. You can always use exclusively generic C++ for the rest of your program, and use Qt ...


15

Copy on write is used in situations where you very often will create a copy of the object and not modify it. In those situations, it pays for itself. As you mentioned, you can pass a const object, and in many cases that is sufficient. However, const only guarantees that the caller can't mutate it (unless they const_cast, of course). It does not handle ...


14

I agree with nearly all of the reasons discussed above however a lot of people here have said they wouldn't use Qt because of the extra overhead that it brings with it. I disagree with that because all the most common languages today (Java, C# and Python) carry a fair bit of overhead themselves. Secondly, Qt makes programming with C++ so easy and straight-...


14

The book you are reading was published in 2007. The C++ API for managing threads wasn't standardised until 2011. At the time, on different systems you had to use entirely different platform-specific libraries (pthreads, win32 threads, etc). Now, this is no longer true. Your book is out of date.


12

Ironically, I'd say Qt's power is also one of the drawbacks. There are so many powerful constructions and extensions, code you write in Qt easily becomes highly entrenched in the "Qt way". Trying to extract functionality into another language not only means a re-write, you need to know a lot of Qt-specific technology. Qt's breadth means that hiring ...


12

Considering that Qt has its own meta-compiler that you have to process your source files with, it's hard to consider Qt code to be "just C++". But more importantly, the style of C++ that Qt uses and encourages is something that, to the rest of us, was last seen around 1995. Really, it's an attempt at making C++ as Java-like as at all possible. It misses ...


12

Addressing the question about cleanup code: yes, there is a way, it's called RAII (for Resource Acquisition Is Initialization, an acronym whose limpid clarity is rivalled only by CRTP), and it is both idiomatic and highly recommended (eg, by the C++ Core Guidelines) You'll see there is built-in support for RAII for some common types in the form of std::...


11

This genuinely isn't an attempt to start a flame war, I just wanted to address some of the points. Probably the real reason that Qt isn't more widely used is that it's C++ and fewer people use c++ for desktop apps. Qt is not a C++ library. It requires a separate compilation step, which makes the build process much more complicated when compared with ...


11

Do you want to know how stepping on the accelerator makes the car go faster, or do you only care that stepping on the accelerator makes the car go faster? You are seeing the benefit to black box programming, which is a great way to design a system when all the boxes work. Someone has to make the black boxes though and if you want to be that guy/girl then ...


11

ABC - ALWAYS BE CODING. It's really that simple. One of my favorite ways of getting to know a language is to write a toy interpreter for a subset of the language in the language itself or if that's not your thing then maybe a ray tracer or something else that's just big enough to be non-trivial but not so big that it can't be finished in a month or so. The ...


11

I could give you some rough guidelines as to how to create the equivalent GUI for a CLI app, design-wise. How you would actually make the calls is out of the scope of this answer. switches like -p -v etc are checkboxes mutually exclusive options are a group of radio buttons parameters that are a filename are a textbox with a "choose" button that shows a ...


10

I'll go the other direction on this one: if your team has linux experience and familiarity, and you run your own servers, outsourcing to a .NET shop will be a disaster. You won't have the experience to rein in the outsourcers when they get crazy, your linux and PHP intuitions will fail you in the Windows environment, you won't easily spot goofy .NET ...


10

Qt does not use the standard C++ library, but has its own QString, QVector, QMap, ... This means you have to make an important design decision: what parts of the application will use QString and which parts will use std::string? Using std::string in some parts and QString in other parts, means you'll have to convert between QString and std::string on the ...


9

Is Learning C++ Through The Qt Framework Really Learning C++ Maybe. I'd have to see the code you're putting in your event handlers. Really though, don't be obsessed with how much you "know". We all use windowing frameworks and we're all still learning. Just keep coding/reading new things and you'll continue learning C++. Learning a new windowing ...


9

I would say you should do the contrary, a good design would be for your application to be able to run whatever its context is. That's why for every application I code, I create a CLI tool that implements the logic, and then I implement a GUI. Where am I heading to ? You're creating a MainController object that holds the world, and then modifies the Ui_Game ...


9

Well, if you have the same kind of code multiple times, meaning switch on type-code and then use identical code with that type, how about using a template and generic lambda? template <class F> auto do_typed(int type, F f) { switch(type) { case CV_8U: return f(std::enable_if<true, std::uint8_t>()); case CV_8S: return f(std::...


8

As nicely explained in Teach Yourself Programming in Ten Years, you should follow next steps : Get interested in programming, and do some because it is fun. Make sure that it keeps being enough fun so that you will be willing to put in your ten years/10,000 hours. Program. The best kind of learning is learning by doing. To put it more technically, "the ...


8

C/C++ is fast. The reality is, most apps wont need that performance with the state of the current hardwares. The usual way is to develop the application in a high level language, like python, than optimize when needed with lower level languages, like C/C++. Python will give you a big productivity boost, it's easy to learn and reasonably fast. There is ...


7

The reason is simple: it does not have good bindings to all mainstream languages, and it is not magically always appropriate for the job at hand. Use the right tool for the job. If I'm writing a simple command-line application, why would I bloat that up with Qt just for the sake of it? As a more general answer (which I can give because I'm relevant here), ...


7

So we did an analysis of the two (+ HTML 5) for our purposes and found that JavaFX narrowly won out due to our familiarity with Java and Java based tooling and support stacks. Our methodology was to list 20 criteria and rank each technology out of 10 for each. For example, i18n, ease of hiring, x-platform support, mobile support, strength of commnuity, ...


7

As you already discovered, putting all unit tests into one huge file is not a good practice (same as putting all classes into one file is bad as well, although it compiles a bit faster). You should create a subdirectory unittests where all unit tests go. It should be one file per class. This way you do not clutter your code with unit tests. If you can, ...


Only top voted, non community-wiki answers of a minimum length are eligible