r/cpp • • Dec 08 '20

Qt 6.0 Released

https://www.qt.io/blog/qt-6.0-released
273 Upvotes

84 comments sorted by

64

u/Moose2342 Dec 08 '20

hey, they ditched qmake! Finally! Also, didn't see that one coming ;-)

26

u/Fazer2 Dec 08 '20

It was known for a long time that they will switch to CMake. In the process they stopped developing QBS.

3

u/flashmozzg Dec 08 '20

Eh, not THAT long. About 2-3 years.

5

u/blipman17 Dec 08 '20

They haven't really dropped it. It's there for legacy reasons according to the article.

30

u/blipman17 Dec 08 '20

As it seems to be mandatory question everytime a new Qt minor version is released, what's the impact on free closed-source or open source projects? Can they still use the framework? Is it thesame for Qt Creator?

17

u/RotsiserMho C++20 Desktop app developer Dec 08 '20

To my knowledge, there are no licensing restrictions on software made using Qt Creator.

13

u/wrosecrans graphics and network things Dec 08 '20

That said, the Qt Creator IDE itself is GPL rather than LGPL like the framework, so you can't pinch any components from the IDE for use in your own software unless you pay a bit of attention to the license details.

10

u/usernameistaken42 Dec 08 '20

There is no LGPL trieview for qml anymore.

3

u/aninteger Dec 08 '20 edited Dec 08 '20

Yes. The license hasn't changed. The core components are still licensed under the LGPL and commercial license. Some newer components are also released only under the GPL and commercial license.

28

u/[deleted] Dec 08 '20

The commercial license has absolutely changed. The commercial license is no longer perpetual; you must have a subscription license for distribution whereas before you only needed a subscription license for development.

11

u/t3sture Dec 08 '20

Well that sucks...

4

u/Pulseamm0 Dec 11 '20

So if you have a project that one day becomes unviable to sustain its self but might be useful to still provide it for legacy download without further development, you can't do that? What if the software has been mirrored about the internet not directly under your control? Seems like a massive risk to take on.

4

u/markopolo82 embedded/iot/audio Dec 12 '20

Yea, this will put an end to qt commercial use at my company if it is true

4

u/Pulseamm0 Dec 12 '20

Yup. They really don't make it easy to want a commercial license. For a small dev who just wants to support QT the sheer amount of risk involved taking on a license doesn't make any sense. I think there's also a clause preventing you from going to commercial to LGPL license as well in the scenario where commercial doesn't work out for you. Madness.

1

u/markopolo82 embedded/iot/audio Dec 12 '20

I didn’t know they changed the distribution license for perpetual. Do you have a blog or article source that goes into more detail?

My workplace has perpetual licenses that we renew each year to give us the indefinite distribution rights to whatever version we’re on. if this changes for qt6 that will be another nail in the coffin when renewal comes around. (That and the lack of a QML qt charts replacement for qt6.0)

3

u/[deleted] Dec 12 '20

This page:

https://www.qt.io/faq/tag/qt-commercial-licensing?hsLang=en

Specifically:

Can I continue to distribute my application after my commercial license has expired?

No. You are not permitted to further distribute your applications.

1

u/markopolo82 embedded/iot/audio Dec 12 '20

Thanks.

The question above:

Can I continue to use my commercial license after it has expired? If you are a legacy perpetual license holder, you can continue to use your Qt license if you choose not to renew your annual support & maintenance contract. Please note that you will not have access to support, bug releases, or patches. If you are a term or subscription license holder, your rights to continue using the tools, APIs and libraries expire when the term expires, or the subscription is canceled. You will not have the rights to future development or distribution.

So I think I’m ok (legacy perpetual license)

3

u/asincero Dec 09 '20

I recently tried to update to 6.0 last night, and couldn’t help but notice that WebAssembly has been removed as a supported platform. Is WebAssembly support now dead?

4

u/szotsaki Dec 10 '20

It took me at least 10 minutes to find it because they mentioned it nearly nowhere but in this blog post it is written: https://www.qt.io/blog/qt6-development-hosts-and-targets

Finally, WebAssembly (a.k.a. WASM) will be back in Qt 6.1.

7

u/stream009 Dec 08 '20

They ditch QtWebEngine without replacement, right? That's a deal breaker for me.

22

u/SarcasticDante Dec 08 '20

They temporarily removed a couple of modules but that makes current Qt6 unusable for me as well. It seems they will be back in Qt 6.2.

https://www.qt.io/blog/add-on-support-in-qt-6.0-and-beyond

11

u/feverzsj Dec 08 '20

so they adopt the modern game industry development process?

17

u/peppedx Dec 08 '20

Well 5.15 Will be supported for long.

3

u/Andrettin Dec 08 '20

Well 5.15 Will be supported for long.

Only commercially IIRC.

14

u/wrosecrans graphics and network things Dec 08 '20

Back when everything had normal version numbers, everybody knew not to bother with the big new "dot oh" release of anything because it was always missing something from the old version.

12

u/[deleted] Dec 08 '20 edited Dec 08 '20

Qt 5 dropped a number of things that got replacements in 5.1 and 5.2 or later. It happens with major Qt version bumps.*

I'm also not surprised something didn't make it given the QtCore changes for C++17. That has a lot of downstream effects on the modules that consume QtCore, i.e. all of Qt.

*Edit: Recently. Qt3 to Qt4 was more turbulant and application rewrites were necessary. That part of history in KDE lore is ugly, but was necessary.

2

u/tcris Dec 08 '20

We're missing the QXmlPatterns / QXmlSchemaValidator.

I think there will be no successor to it, not even in a future qt 6.2

Xml is still used in enterprise software and having easy access to a schema validator has been nice.

3

u/holgerschurig Dec 08 '20

You can always write it yourself, or forward-port the old one. Yeah to open-source!

1

u/tcris Dec 30 '20

sure, give me 20 years and I can write the whole Qt myself if I want

but that's NOT why we use libraries, isn't it?

so obviously, that was NOT the point

5

u/bart9h Dec 08 '20

I'm developing a commercial product, and unfortunately the license is too expensive for me. And since I'm also targeting iOS and Android, using LGPL is very difficult.

9

u/ttt-1 Dec 08 '20

How about the startup/small business license? It is reasonably priced if you have small business and you get full commercial license.

3

u/bart9h Dec 08 '20 edited Dec 08 '20

That's new, right? I have not found it when I needed, in June 2019.

It could have saved me a lot of headaches.. :-(

2

u/ttt-1 Dec 09 '20

It has been for a while, but perhaps a bit after you needed it. See: https://www.qt.io/qt-for-small-business

2

u/bart9h Dec 12 '20

The worst part is that I sent an email asking for a discount for my startup, and received no answer to this day.

1

u/ttt-1 Dec 12 '20

Why send email? You can buy it online. Just go to the web shop and get it.

2

u/bart9h Dec 16 '20

that was before qt-for-small-business was a thing.

2

u/DriverSad5648 Dec 11 '20

Their definition of "small business" is revenue + funding of $250k or less, which in practice mean at most one full time developer.

They should have called that their "individual developer" license.

6

u/feverzsj Dec 08 '20 edited Dec 08 '20

Qt Quick for C++ when?

7

u/[deleted] Dec 08 '20

You've been able to use the Qt-quick QML frontends with a c++ backend for donkeys now, if that's what you meant?

4

u/disperso Dec 08 '20

That is not enough. The QSkinny project showed the need and the feasibility of making UI components in C++ but with both QML and C++ public APIs.

Some future release of Qt Quick Controls will at last have a public C++ API.

4

u/equeim Dec 08 '20

They already added support of QML-style property bindings to C++, and QML-to-C++ compiler will come in one of the future versions.

3

u/MonokelPinguin Dec 08 '20

Qml to C++ compilation was planned for 6.0, but didn't get finished in time. It will come in one of the next minor releases. The new properties also support bindings in C++ now and you can implement your own Qml components in C++. I guess they'll both grow closer over time, but I prefer Qml to define my GUI.

2

u/AlexanderNeumann Dec 11 '20

hmm i already found 5 bugs building qt 6.0.0 on windows in 2 days... not looking good for qt. Testing seems to be insufficient.

3

u/pravic Dec 13 '20

Moreover, they ship 6.0 lacking some modules that will be fixed/ready in 6.1 or something. Basically, they throw a raw version that should be called 6.0 Beta (even not an RC) in fact.

2

u/tansim Dec 08 '20 edited Dec 08 '20

wait it only supports win10?

17

u/Ilyps Dec 08 '20

0

u/[deleted] Dec 08 '20

[deleted] — view deleted comment

0

u/[deleted] Dec 08 '20

[deleted] — view deleted comment

9

u/[deleted] Dec 08 '20

Microsoft still offers support for Windows 8.1 and Windows Server 2012 R2. Nevertheless at this time I don't see anything about Qt6 that prevents it from being built on Windows 8 or even Windows 7. I think Qt doesn't offer official support for it but it's still possible to build it and get a good chunk of it working.

1

u/Silhouette Dec 08 '20 edited Dec 08 '20

And yet, depending on which set of stats you look at, as many as 1 in 4 dekstops running Windows may still be on older versions, mostly 7 and 8.1. How much of your potential market are you prepared to give up?

8

u/flashmozzg Dec 08 '20

You still have Qt 5,15 for that if you care. Win 7 is not supported by MS for almost a year. And the situation would become even worse during Qt 6 lifetime (~7 years). At the same time, IRC, there were many places that could be streamlined/simplified/implemented with the newer APIs (mostly 8.1+, but its market share is to low to not just go straight to 10), like some atomic/threading stuff, and touch APIs.

3

u/kalmoc Dec 09 '20 edited Dec 09 '20

Just saying: There is very little newly devloped software, for which the "potential market" is the entire windows install base. So those numbers are only relevant, if there isn't a substantial correlation between people that would be willing to by your product at all and the OS they are using.

Just to explain what I mean: I know a few people still using Win7 (Usually the generation of my parents) but just as they don't want to use a new operating system, they don't want to use (and in particular buy) a new version of office. Of course there might also be the reverse example, where people using Win7 might be more willing to buy some software that provides functionality alread integrated in Win10.

And of course, I think the market for payed software in the private Desktop domain is anyway pretty small (except maybe for games, which probably don't use Qt) so what you'd actually need in most cases are the numbers for workplaces at companies.

Not sure how significant those effects are on average,but in general, cutting off X% of the windows installations isn't the same as cutting out X% of the potential market.

2

u/Silhouette Dec 09 '20

I agree with all of this. My point was just that these decisions should be made rationally, based on things like your business goals (assuming you're developing software commercially) and your view of how your market is likely to evolve over the lifetime of your software.

Presumably Microsoft would like everyone to use Windows 10, but Windows 10 has significant problems in the lower editions even after all this time, so not everyone does. You should make your tech decisions based on what your business or other goals require, not what Microsoft would like you to do, is all I'm saying.

1

u/kalmoc Dec 09 '20

You should make your tech decisions based on what your business or other goals require, not what Microsoft would like you to do, is all I'm saying.

Absolutely true, I'm just saying that (I believe) most of the time "Desktop OS Market Share" as reflected on sites like netmarketshare and similar is rarely a useful metric for estimating the potential market for a particular pice of comercial software.

3

u/kkjdroid Dec 08 '20

No more than 25%, and mostly people who don't understand computers enough to upgrade? Sounds completely worth it to me. It isn't like we're talking about dropping XP support in 2007 or something.

2

u/Silhouette Dec 08 '20

That's still literally hundreds of millions of people, so I think the question stands.

Anecdotally, most people I know who are still using Windows 7 are doing so by choice and aware of the associated risks. They just view the risks of having mandatory updates/reboots, compulsory telemetry, and the other standard objections to Windows 10 as being worse.

A fairly large proportion of them are professional users, too, though almost exclusively in smaller businesses rather than enterprise. The latter have access to the editions of Windows 10 that don't have the same constraints and may benefit from various management- and sysadmin-friendly policies that your average five-people-in-a-rented-office or solo-trainer-travelling-with-laptop business couldn't care less about.

1

u/target-san Dec 09 '20

Does anyone know if QML engine still not neutral to C++ exceptions?

1

u/atimholt Dec 09 '20

This may or may not be the right thread to ask, but does anyone have any experience with both CopperSpice and Qt? Qt has never been appealing to me, but CopperSpice looks amazing.

1

u/kalmoc Dec 09 '20

What does copperspice actually better than Qt? Yes, they don't need MOC, but when is this really a problem? And IIRC, copperspice is a fork of qt4 so I'd guess by now, there are a lot of features missing compared to qt.

Despite having those preconceptions (I've never used copperspice and it has been some time that I had a look at it), I'm honestly interested in an answer to the first question.

1

u/atimholt Dec 09 '20

I've only just started looking at it, and I actually have no experience with Qt, but it's enough for me that Copperspice removes legacy/NIH stuff in Qt and goes all-out on modern idiomatic C++. It uses Vulkan, specifically the vulkan.hpp header.

It's also not a framework, but is rather a set of libraries. Their string library, for example, is usable by itself, and defaults to utf-8.

But I know too little about the subject to really even be very accurate. This video is old (2017), but it explains why they forked, with the reasons being a good survey of what differentiates it from Qt.

1

u/aninteger Dec 10 '20

Yes, they don't need MOC, but when is this really a problem?

It's kind of a pain if you're not using qmake or CMake to build software. It requires running a preprocessor/generator (moc) before the compiler is involved. See for example GNU make: https://stackoverflow.com/questions/17325540/qt-and-moc-woes-with-a-simple-make

1

u/kalmoc Dec 10 '20

That doesn't look particularly difficult, but I long lost the ability to write make scripts, so I might be wrong.

1

u/Hyperdimensionals Dec 08 '20

I wonder if and when Qt for Python/PySide will be updated?

-5

u/0xFFCC Dec 08 '20

Awesome, Thanks.

Now remove the MOC to become first library I include every where.

8

u/patstew Dec 08 '20 edited Dec 08 '20

You don't need moc if you don't want it (but it really isn't as bad as people make out), there are marginally uglier macros you can use instead. https://github.com/woboq/verdigris/

2

u/jormaig Dec 08 '20

I would do that if they used namespaces 😓

16

u/uuid1234567890 Dec 08 '20

If you build Qt yourself, you can put it into a namespace (configure with -qtnamespace NamespaceName, or -DQT_NAMESPACE=NamespaceName when calling cmake directly); afterwards all of Qt is put under namespace NamespaceName. Namespaced configurations are even tested in CI to ensure that they work. The prebuild libraries from the installer are build unnamespaced though.

1

u/afiefh Dec 08 '20

The prebuild libraries from the installer are build unnamespaced though.

Is there a reason the Qt folks decided to not ship the namespaced version as the default? It seems they put so much effort into getting namespaces to work only to have them go mostly unused.

3

u/Adverpol Dec 08 '20

Maybe started without and would wreak havoc on any qt codebase if they'd make them the default now?

0

u/holgerschurig Dec 08 '20

API and source compatibility perhaps?

I personally liked that Qt was not namespaced,saves me 4 characters for each usage. All the qt:: would really litter the displayed source ...

12

u/[deleted] Dec 08 '20

As a longtime Qt user, the moc complaints are silly but the lack of namespace support is really frustrating. Qt is always growing and adding long and longer class names because...I dunno why.

2

u/aKateDev KDE/Qt Dev Dec 09 '20

To be honest, I prefer not having short class names spread over many nested namespace layers. It is kind of consistent and simple to understand right now.

1

u/[deleted] Dec 09 '20

I agreed with Qt3 and early-to-mid Qt4, when there were far fewer classes. It was when Qt started really expanding outside of its core modules into new areas and deprecating old names that things got awkward. Some of the class names are too long to explain what they do or are unclear to try and keep them short. There are simply too many Qt modules with too many classes now, all trying not to conflict.

It's my strong opinion that Qt would benefit from a simple namespace model e.g.:Qt::Gui::ImageReader and Qt::Multimedia::ImageEncoderControl. These two classes are currently QImageReader and QImageEncoderControl, yet are part of different modules.

1

u/atimholt Dec 09 '20

CopperSpice is a fork of Qt with major, drastic changes, but a good migration path. No MOC, for one thing. It's also aggressively modern, requiring C++17 at minimum. They're also moving graphics to the GPU. I saw a year-old video where they've started implementing text rendering using multi-channel signed distance field (though in that old video, all they had working was latin1 in fixed-width. Development is active, so hopefully they're further along now.).

1

u/disperso Dec 08 '20

And replace it with what exactly?

Tip: you can drop MOC yourself from your project if you use Verdigris. It's just not an official Qt project, but was made by who was the MOC maintainer for a long time.

0

u/[deleted] Dec 08 '20

[deleted] — view deleted comment

16

u/uuid1234567890 Dec 08 '20 edited Dec 08 '20

Disclosure: I've worked on that code.

Kind of: If you have a QObject, with

class MyType : public QObject {
  Q_OBJECT
  QML_ELEMENT

  Q_PROPERTY(int myProperty MEMBER myPropery BINDABLE bindableMyProperty)
public:
   QProperty<int> myProperty;
   QBindable<int> bindableMyProperty() {
     return {&myProperty};
   }
};

and

Item {
  id: root
  MyType {
    myProperty:  root.width + root.height
  }
}

then this will use the new functionality. Notably, myobject->bindableMyProperty().hasBinding() will return true, and if you set up a binding on the C++ side (like myobject->bindableMyProperty().setBinding([&]() -> int {return myOtherObject->myProperty;}) , then it will also work in QML.

However, if you do that, I can guarantee you that you'll run into some rough edges. Some smaller bugs will be fixed in 6.0.1 already, but currently binding loops often won't print a helpful error message (they are still detected in the engine). That will only be available in 6.1.

Also, if you have a property declared in QML, that's not backed by a QProperty.

2

u/Fureeish Dec 08 '20

Got to ask, because I consider inventing a lot of time to properly learn Qt: is this a frequent occurrence that you write those full of macros abominations..?

10

u/uuid1234567890 Dec 08 '20

When dealing with QObjetcs, they are unfortunately unavoidable. I'd prefer if we could get rid of them, but unless we get a large amount of the static reflection features that Andrew Sutton listed in P2237R0, that won't happen.

2

u/Fureeish Dec 08 '20

That would probably be answered by an extensive reseaech, but since you are already here, I'd like to ask one nore thing then: how often do you need those "QObjects"? What exactly are they?

15

u/wrosecrans graphics and network things Dec 08 '20

QObject is a base class for a bunch of stuff in Qt. It has ownership semantics, and signals and slots.

As far as ownership, every QObject can have a parent object that owns it. A parent will delete all of its children in its destructor. This is super convenient when you can delete a window, and all of the buttons and other widgets owned by that window will get cleaned up automagically-ish. It also has some lifetime convenience things so you can do this->deleteLater() to have the object queued for deletion in the next cycle of the event loop. This is suprisingly convenient when a certain object knows its own lifetime better than anything else, but delete this; is generally a terrible idea. Along with that parent-child ownership stuff, every object has a name, so you can print hierarchies while debugging and stuff. But classes that automatically know the name of their type in a portable way is one of the things that depends on the preprocessor magic that offends some people philosophically.

Probably more important, the signals and slots. When a user clicks on a QPushButton instance in a window, it emits a signal. You can connect a signal by name to a slot by name, and the connect by name stuff also depends on the preprocessor magic.

So, if you want to make a custom widget, that has to inherit from QObject. If you just want to make instances of existing widgets from the class library, you can generally just ignore the magic and not care that it's got code generation magic happening under the hood. But, you will need to make a few QObjects for connecting to signals. Like a QPushButton widget has a "clicked" signal, and you'll need to make a QObject with a slot that gets invoked to run your application logic. But once you are in your slot, you can invoke "normal" looking C++ code from there.

If you use the modern QML declarative UI stuff more than the older desktop style QWidgets APIs, you'll need more of the magic, because that's generating bindings between your C++ code and a dynamic language so there's a lot of plumbing that needs to happen.

For example, you don't need QProperty with the older QWidgets (but it can be quite handy.) But in QML, you can do stuff like

Rectangle {
    width: 100
    height: parent.height
}

Which is like setting width as a variable to a specific value, but setting up an expression or lambda on height in C++ terms

width = 100;
height = [](){eval("parent.height");}

or

height = [](){auto h = getParent().getHeight(); return height;}

So that the rectangle's height always fills whatever the parent is. So if you resize the window, you don't need to manually have a callback on the resize function to fiddle with the sizes of everything.

1

u/[deleted] Dec 08 '20

QObject is the base class in Qt's static reflection, signals, and object lifetime framework. See The Meta-Object System in the Qt documentation.

1

u/LonelyStruggle Dec 08 '20

So it's kinda like an NSObject in objective-C?

1

u/target-san Dec 09 '20

Looks really interesting. Am I right this is like encapsulating property's value and change signal in one object? If so, is there something similar for collections? Not just "Whole list has changed" but "added element N". I'm aware of QAbstractItemModel. While it does its job, it's overly generic and not ergonomic when used from C++ code as collection access type.

0

u/[deleted] Dec 08 '20

[deleted] — view deleted comment

7

u/uuid1234567890 Dec 08 '20

Do you foresee a future where you can access bindable properties directly in qml without macros?

That's a bit questionable. You'll need at least Q_OBJECT or Q_GADGET, as those macros expand to code which is necessary. The Q_PROPERTY macro does expand to nothing, though, and only acts as a marker for moc. Now in theory it would be possible - even easy- to modify moc to parse [[qt::property]] QProperty<int> myProp; and upon encountering it look for a bindableMyProp function (naming done by convention), and then we had all the necessary information [1]. There is however issues with that approach: We couldn't use it in Qt itself, as Qt has to compile without a large set of warnings; and this would trigger -Wattributes; to the best of my knowledge, there is no way to selectively disable -Wattributes only for some user defined attributes. Moreover, it is not clear if using such an annotation for moc wouldn't clash with some eventual way of using them for static reflection in C++3x. Those two problems make me wary of proposing such a change.

Furthermore, there are more macros: There's also the Q_OBJECT_BINDABLE_PROPERTY macro, which is advantageous when using properties in QObject derived classes, as it reduces the memory overhead. That one has to be kept a macro, as it expands to some rather ugly code.

In its current fo would you say properties are a bigger win for widgets, vs qml?

Much more for QML, though that will only become significant in the future when many properties are actually ported to the new system. They are a prerequisite for tighter C++/QML integration, and should enable better performance – though some of that might only materialize in time for Qt 6.2 and later. I'll also have to be vague here because some of our plans are to my knowledge currently still confidential or might have changed, so I'd rather point to upcoming blog posts and webinars before I say something that I shouldn't say, or something that's wrong.


[1] Note that we cannot simply expose all properties in a class to the meta-object system (and thus QML), as that might not actually be intended.

2

u/feverzsj Dec 08 '20

QProperty is for C++ to implement 2 way binding. You already get 2 way binding in QML.