Qt 6 - Episode 2 - Migrating from Qt 5 to Qt 6

preview_player
Показать описание
In this video series we will cover Qt 6. In this episode we cover some issues migrating code form Qt 5 to Qt 6. Along with some simple fixes, using the Core5Compat module, cmake, qmake, and testing Core, Widgets, and QML.

Qt 6 youtube videos by Bryan Cairns

Intro: (0:00)
Notes: (3:36)
QVariant from QString: (6:05)
Changes to QDateTime: (7:04)
QLinkedList: (7:40)
QTextCodec: (8:44)
QString append: (9:43)
QTextStream and endl: (10:15)
Dptr is a QScopedPointer: (11:32)
QSysInfo changes: (12:12)
QXmlStreamReader: (12:46)
QTcpSocket changes: (13:42)
QSslSocket changes: (14:27)
QNetworkAccessManager changes: (15:25)
Qt Concurrent changes: (16:11)
QString sprintf: (17:09)
QStateMachine: (18:04)
QML File Dialog: (19:02)
QRegExp: (20:43)
QCloseEvent: (21:25)
QListWidgetItem: (21:57)
WindowFlags: (22:56)
QML Menubar: (23:30)
Outro: (24:49)
Рекомендации по теме
Комментарии
Автор

Just a note: at 1:10 when you say that the old modules are still in there, actually you are looking at the same "Removed Modules in Qt 6.0" section.

rafaelgm
Автор

One objection: "\r\n" is not the correct replacement for endl for 2 reasons.
1. Qt just like almost all C++ code and libraries uses plain '\n' to represent newlines, they are converted to "\r\n" only when writing to a text file on Windows, and this conversion happens automatically under the hood, but you need to tell Qt that you're opening a text file by using the QIODevice::Text flag.
2. endl (both in Qt and in std) does not only insert a newline, but also flushes the stream buffer, which may or may not be desirable.
So the correct would be something like (stream << '\n').flush(), but the best is of course the Qt's true replacement, which is Qt::endl.

Youda
Автор

At 24:09, you imported Qt.labs.platform last, which also has a MenuBar component, but that MenuBar is a direct subclass of QObject. The MenuBar from Qt Quick Controls 2 is a subclass of QQuickContainer (Container from QQC2), which is a subclass of QQuickControl, which is a subclass of QQuickItem.

NoahDVS
Автор

10:44 QTextStream and endl: You need to add "Qt::" instead of adding "std::".

argama
Автор

Amazing work, will probably help us save a lot of time. Thank you!

solidreactor
Автор

You need to replace endl with Qt::endl.
I use:
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
# define qt_endl Qt::endl
#else
# define qt_endl endl
#endif

JonasKvinge
Автор

¿lo recomendable sería esperar a que Qt 6 tenga todos los módulos nuevamente, y mientras eso sucede utilizar Qt 5?

DuarteCorporationTutoriales
Автор

I have been fighting 6.0... for some time now and even though I get a good compile, none of my QPushButtons don't work. Can click on it but it does nothing. Can't even debug it!

mradaChris
Автор

Hey! I have always followed your tutorials on Qt back in the old days and it helped me a lot! if you don't mind I want to ask a question:
I'm making an application that grabs the video footage from my game capture card, I already got the camera working fine. But I also want to play the audio back to the user, so sort of like OBS when you add the capture source it is also able to get the audio from it, do you might know how would I be able to achieve that? The capture card audio source is not part of audio input on PC like microphones, so QAudioDeviceInfo doesn't have it ;(

brianuuuSonicReborn
Автор

I cannot for the love of all that is holy get Qt5compat to work with qt6. Any, ideas?

Biffmester
Автор

What do I use instead of QtMultimedia for 6.0? I get unknown module 'multimedia' when I try to build. I see it's been removed, but they don't tell you what to use instead!

craigdanielmaceacher
Автор

i thought they removed qml components versions but they are still there .

Why ?

parasbhanot
Автор

Most of the changes seems to make Qt behave more like STL library containers and pointers.

PhilipBonev
Автор

Are there any improvement Concerning Qt Designer ?

thomasheinzm.
Автор

Great job, like always! There's also confusing thing with QML TreeView that was apparently removed.. I won't migrate my apps to Qt6 yet. Waiting for the next versions..)

МаксимМаксимов-щдч
Автор

“Ancient egyptian algebra” 😄 gotta remember that!

flying-sheep
Автор

One thing I absolutely hate about Qt is that they tweak with a lot of the usage of the functions, leaving us in unfamilliar territory. I have perfectly running code in qt 5 and now I gotta invest days to migrate it to qt 6. Yikes..

mustafaozcelikors
Автор

What are the Consequences to us who just use Python ?

thomasheinzm.
Автор

Dude when is the course coming for QT 6? Waiting for it 🔥

futegiko
Автор

im frustated on how Qt system is designed, it makes it alot harder to learn Qt Quick because all the resources to learn QML are based on Qt5

lickguitars