Short, but I found more enlightenment in these 5.5 minutes than I have in a month of trying to understand QML + C++. Qt are really doing a fantastic job at documenting everything, but they do need to do better at providing "Starter content" for QML. I love technical docs to work with, but that's not necessarily the first thing that I want to read about subject. So: keep going with this kind of stuff.
VoidRealms the two major two things I'm still struggling with are QML as a language and how exactly it interacts with c++. All the resources on QML that I have found jump straight into a combination of the two. What I'm looking for is something akin to Google's intro to Python: it doesn't try to teach programming, it only introduces the syntax and "style" of the language. Understanding the interaction with c++ might be partially solved by properly understanding the language. But there, I feel that most material either tries to stay within QML or the approach is a bit too advanced for a first timer in the language. As I'm currently on the go, I can't link concrete examples, but I'll be sure to follow up with that if that would help you. In any case, I really, really appreciate you asking for suggestions. That kind of attitude makes me love Qt.
Hi Jan, Thanks for the input! Did you have a look at this? doc.qt.io/qt-5/qml-tutorial1.html While it sadly lacks Bryan's dulcet voice, there are examples and visuals that start you off at Hello World. There was also an aptly named "Introduction to QML" webinar, but it must have gotten lost in the transition to our new website. Will have a look. We might also just make a new one in the not-too-far future. Good point :)
Hi, thanks for reaching out again and please excuse the late reply. I did see know the page you linked to, but somehow missed part 2 and 3 of that tutorial. Especially the page about transitions was quite informative. The tutorial is actually also a good example to highlight the things that keep throwing me off (and please keep in mind that these things are my own, personal observations and I can imagine someone coming to the exact opposite conclusion): looking at the Text type, the syntax seems to be a bit inconsistent to me (I can read it and understand it, it's just not what I would intuitively write). As a JS developer, I would have expected it to look a bit like this (this is obviously neither JS nor QML, just what would feel intuitive to me): Text { id: 'helloText' // I realise this is akin to a variable name, but having this without the quotes always keeps me wondering if this shouldn't be initialised itself somewhere (or if this is indeed a special type of primitive literal that might have more uses I'm not aware of) text: "Hello world!" y: 30 anchors.horizontalCenter: page.horizontalCenter // what type is page.horizontalCenter? Is it a reference to something like a Point? Is it itself a Point? font.pointSize: 24 font.style: Text.bold // an enum value (or maybe a string) seems to make more sense here } Please note I'm not at all saying that the language is terribly designed! I'm sure there are good reasons to why these things work the way they do. It's just that I'd very much like to understand those reasons to avoid having to search for an exact match of what I'm trying to do so I can copy it. As stated above, I think Google's tutorial on Python (developers.google.com/edu/python/introduction) does a fantastic job of presenting the particulars of the language in a very concise but understandable fashion. They show some code and explain the 'weird bits' (e.g. that Python strings are not unicode, that there's no ++ operator on numbers etc...). It's not really a tutorial to write a particular program, but more of a 'conversion guide'. I realise that going the 'long way around' by following the route from Hello World step by step, but I found that I learn best if I can feel like I'm making it up as I go instead of exactly recreating examples (and the regular doc (such as the page on the context doc.qt.io/qt-5/qqmlcontext.html) has exactly this kind of examples, it's just the really basic but fundamental things (e.g. what primitive types are there?) that keep throwing me). Once more, thanks A LOT for caring and thanks for reading through this massive comment. Qt and Brian are amazing and I'm definitely looking forward to that webinar ;D.
There are some problems with your code Brian. First, your class getters/setters are marked private, so I'm not even sure why C++ allows you to call them from QtQuick. Then, you shouldn't be calling stopwatch.best = 3.0 at the 3:50 mark, you should of course be using the setter: stopwatch.setBest(3.0) I get the whole C++/QML property system interface and all, but I'm really not sure why this code even works given that (as I mentioned above) your C++ interface methods are in the private section of your Stopwatch class header. The same goes for the display/setDisplay methods. Very interesting...
Remember! QML cannot connect to c++ objects via events. That is, this is not a safe method if the c++ object is in a different thread than the QML scene. If you connect c++ and QML from c++, you can create a Qt connection::Queuedconnection. This is already safe for different threads
I like this framework, but why does this process have to be so tedious? Why can't you just get a button click signal in the C++ backend and run a function from there?
Could you maybe do a video tutorial for using contextproperties and contextobjects? I know that they are realy easy to use but explaining them to developers can be hard. Also I would like an entry tutorial on the context* stuff and a deep tutorial (creating new QQmlContext on the fly as a subcontext with own contextproperties/-object, explaining the context hierary, and maybe some other deep and interesting stuff)
Please slow down, I came here to learn about signals and slots, as I already have my function and button setup, I literally just need to connect them.. please be more clear and simple next time.
Have a look at the previous tutorial provided by VoidRealms (the same guy in this video, but only on his channel). Signals and slots is described in detail there, but in terms of Qt (C++ code) but the concepts carry over.
Short, but I found more enlightenment in these 5.5 minutes than I have in a month of trying to understand QML + C++.
Qt are really doing a fantastic job at documenting everything, but they do need to do better at providing "Starter content" for QML. I love technical docs to work with, but that's not necessarily the first thing that I want to read about subject. So: keep going with this kind of stuff.
What sort of starter content are you looking for?
VoidRealms the two major two things I'm still struggling with are QML as a language and how exactly it interacts with c++.
All the resources on QML that I have found jump straight into a combination of the two. What I'm looking for is something akin to Google's intro to Python: it doesn't try to teach programming, it only introduces the syntax and "style" of the language.
Understanding the interaction with c++ might be partially solved by properly understanding the language. But there, I feel that most material either tries to stay within QML or the approach is a bit too advanced for a first timer in the language.
As I'm currently on the go, I can't link concrete examples, but I'll be sure to follow up with that if that would help you.
In any case, I really, really appreciate you asking for suggestions. That kind of attitude makes me love Qt.
:)
Hi Jan,
Thanks for the input!
Did you have a look at this? doc.qt.io/qt-5/qml-tutorial1.html
While it sadly lacks Bryan's dulcet voice, there are examples and visuals that start you off at Hello World.
There was also an aptly named "Introduction to QML" webinar, but it must have gotten lost in the transition to our new website. Will have a look. We might also just make a new one in the not-too-far future. Good point :)
Hi, thanks for reaching out again and please excuse the late reply.
I did see know the page you linked to, but somehow missed part 2 and 3 of that tutorial. Especially the page about transitions was quite informative.
The tutorial is actually also a good example to highlight the things that keep throwing me off (and please keep in mind that these things are my own, personal observations and I can imagine someone coming to the exact opposite conclusion): looking at the Text type, the syntax seems to be a bit inconsistent to me (I can read it and understand it, it's just not what I would intuitively write). As a JS developer, I would have expected it to look a bit like this (this is obviously neither JS nor QML, just what would feel intuitive to me):
Text {
id: 'helloText' // I realise this is akin to a variable name, but having this without the quotes always keeps me wondering if this shouldn't be initialised itself somewhere (or if this is indeed a special type of primitive literal that might have more uses I'm not aware of)
text: "Hello world!"
y: 30
anchors.horizontalCenter: page.horizontalCenter // what type is page.horizontalCenter? Is it a reference to something like a Point? Is it itself a Point?
font.pointSize: 24
font.style: Text.bold // an enum value (or maybe a string) seems to make more sense here
}
Please note I'm not at all saying that the language is terribly designed! I'm sure there are good reasons to why these things work the way they do. It's just that I'd very much like to understand those reasons to avoid having to search for an exact match of what I'm trying to do so I can copy it.
As stated above, I think Google's tutorial on Python (developers.google.com/edu/python/introduction) does a fantastic job of presenting the particulars of the language in a very concise but understandable fashion. They show some code and explain the 'weird bits' (e.g. that Python strings are not unicode, that there's no ++ operator on numbers etc...). It's not really a tutorial to write a particular program, but more of a 'conversion guide'.
I realise that going the 'long way around' by following the route from Hello World step by step, but I found that I learn best if I can feel like I'm making it up as I go instead of exactly recreating examples (and the regular doc (such as the page on the context doc.qt.io/qt-5/qqmlcontext.html) has exactly this kind of examples, it's just the really basic but fundamental things (e.g. what primitive types are there?) that keep throwing me).
Once more, thanks A LOT for caring and thanks for reading through this massive comment. Qt and Brian are amazing and I'm definitely looking forward to that webinar ;D.
Hello, i have a question, where is the prevous part of this tutorial? This video doesn't start than blank project.
This could have saved me a lot of time if it was out 1 month ago :) I had to learn it the hard way. Thanks for the tutorial regardless.
There are some problems with your code Brian. First, your class getters/setters are marked private, so I'm not even sure why C++ allows you to call them from QtQuick. Then, you shouldn't be calling stopwatch.best = 3.0 at the 3:50 mark, you should of course be using the setter: stopwatch.setBest(3.0)
I get the whole C++/QML property system interface and all, but I'm really not sure why this code even works given that (as I mentioned above) your C++ interface methods are in the private section of your Stopwatch class header. The same goes for the display/setDisplay methods. Very interesting...
Remember! QML cannot connect to c++ objects via events. That is, this is not a safe method if the c++ object is in a different thread than the QML scene. If you connect c++ and QML from c++, you can create a Qt connection::Queuedconnection. This is already safe for different threads
please give a link to an example
Is that void realms? Crazy 😝
haha~~
Thank you very much for this video. It really helped me figure out C++ integration. Qt Quick is pretty awesome.
Which version of Qt?
strange that slots are not required for the properties but signals are required for the NOTIFY part of it.
Thank you, it's exactly what I'm looking for.
where can I download this project example please?
Great one which is focused on the topic.
Awesome tutorial ! Thanks a lot
I like this framework, but why does this process have to be so tedious? Why can't you just get a button click signal in the C++ backend and run a function from there?
Hello, Thanks for the great video. Why are the functions of Stopwatch that are called from QML not taged with Q_INVOCABLE?
how i integrate a qml ApplicationWindow with qt application C++
So we don't need to make a Q_PROPERTY in our class for all our public methods that we want use on the QML frontend?
I think qml has visibility of c++ objects' Q_PROPERTY, public slots and Q_INVOKABLE
where is this example full code?
i don't have a 'Headers' folder in my project, what can i do ???
Add a new clas c++ to ur project. it will generate a cpp and header
Very useful. I love Qt
Could you maybe do a video tutorial for using contextproperties and contextobjects? I know that they are realy easy to use but explaining them to developers can be hard.
Also I would like an entry tutorial on the context* stuff and a deep tutorial (creating new QQmlContext on the fly as a subcontext with own contextproperties/-object, explaining the context hierary, and maybe some other deep and interesting stuff)
Hi Kai, does something like this help? doc.qt.io/qt-5/qqmlcontext.html
Great tutorial!
Thank you for this video.
absolutely amazing! yes!
because they do not publish the source code of this program
Code?
Great! Now please show us how to do this properly for a TCP client including error handling
3 years later... dozens of comments asking for the source... are you guys asleep over there at Qt?
Way to complicated!
Toogle!
Please slow down, I came here to learn about signals and slots, as I already have my function and button setup, I literally just need to connect them.. please be more clear and simple next time.
Have a look at the previous tutorial provided by VoidRealms (the same guy in this video, but only on his channel). Signals and slots is described in detail there, but in terms of Qt (C++ code) but the concepts carry over.
th-cam.com/video/JtyCM4BTbYo/w-d-xo.html
Qwertu