Sign up for the KDAB Newsletter
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Find what you need - explore our website and developer resources
13 August 2024
The class QVariant is a truly important class in Qt, which offers the possibility to provide anything to a function, or return anything from one. If you know modern C++, then it is a bit like std::any, and if you are more familiar with plain C, then you will find some resemblances to its union.
Links:
* Avoiding QVariant::fromValue in QWAM: https://youtu.be/caNufuHsUjs?list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI
* Documentation on QVariant QAbstractItemModel: https://doc.qt.io/qt-6/qabstractitemmodel.html#data
* Adapting Column Content to Size in QWAM: https://www.youtube.com/watch?v=1oGZr4X3GXo&list=PL6CJYn40gN6gf-G-o6syFwGrtq3kItEqI
* KDAB Rust training info: https://training.kdab.com/portfolio/rust/
The example code showcased in this video is available here: https://github.com/KDABLabs/kdabtv/tree/master/Programming-With-Qt-Widgets
0:00 Introduction
0:25 Union datatype or union
4:47 QVariant
5:55 Rust training KDAB
6:10 QVariant
9:27 Q_DECLARE_METATYPE
11:39 qRegisterMetatype
15:51 QVariant usages
21:13 Conclusion
All 'Introduction to Qt Widgets - Module 1' videos: https://www.youtube.com/playlist?list=PL6CJYn40gN6hgf7zCKF2Rv9Y0WoN8RVGf
All 'Introduction to Qt Widgets - Module 2' videos:
https://www.youtube.com/playlist?list=PL6CJYn40gN6j_c41CFMprvg9EiWz0WdSy
All 'Introduction to Qt Widgets - Module 3' videos:
https://www.youtube.com/playlist?list=PL6CJYn40gN6hWZO_viEf1rfjgk4E6SCKd
All 'Introduction to Qt Widgets - Module 4' videos:
https://www.youtube.com/playlist?list=PL6CJYn40gN6iXUNQMb2GkEjV_oK6Xid9-
All 'Introduction to Qt Widgets - Module 5' videos:
https://www.youtube.com/playlist?list=PL6CJYn40gN6h1tsLAETdrrFlsVMeYpiHI
Stay on top of the latest news, publications, events and more.
Go to Sign-up
Learn Modern C++
Our hands-on Modern C++ training courses are designed to quickly familiarize newcomers with the language. They also update professional C++ developers on the latest changes in the language and standard library introduced in recent C++ editions.
Learn more