QML - Integration with C++ {tutorial}

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 46

  • @janhettenkofer3814
    @janhettenkofer3814 6 ปีที่แล้ว +29

    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
      @VoidRealms 6 ปีที่แล้ว +1

      What sort of starter content are you looking for?

    • @janhettenkofer3814
      @janhettenkofer3814 6 ปีที่แล้ว +4

      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.

    • @VoidRealms
      @VoidRealms 6 ปีที่แล้ว +2

      :)

    • @QtStudios
      @QtStudios  6 ปีที่แล้ว +1

      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 :)

    • @janhettenkofer3814
      @janhettenkofer3814 6 ปีที่แล้ว

      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.

  • @macinm97
    @macinm97 6 ปีที่แล้ว +34

    Hello, i have a question, where is the prevous part of this tutorial? This video doesn't start than blank project.

  • @xmfcx
    @xmfcx 6 ปีที่แล้ว +7

    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.

  • @bluehornet6752
    @bluehornet6752 2 ปีที่แล้ว +1

    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...

  • @ЯрославРосс
    @ЯрославРосс 3 ปีที่แล้ว +2

    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

  • @gamerecords_site
    @gamerecords_site 5 ปีที่แล้ว +3

    please give a link to an example

  • @platin2148
    @platin2148 5 ปีที่แล้ว +9

    Is that void realms? Crazy 😝

    • @mdwdyx
      @mdwdyx 5 ปีที่แล้ว

      haha~~

  • @world_of_hein
    @world_of_hein 4 ปีที่แล้ว

    Thank you very much for this video. It really helped me figure out C++ integration. Qt Quick is pretty awesome.

  • @saschal7771
    @saschal7771 2 ปีที่แล้ว

    Which version of Qt?

  • @taeheekim8314
    @taeheekim8314 4 ปีที่แล้ว

    strange that slots are not required for the properties but signals are required for the NOTIFY part of it.

  • @3210oo
    @3210oo 6 ปีที่แล้ว +1

    Thank you, it's exactly what I'm looking for.

  • @santoelectron
    @santoelectron 4 ปีที่แล้ว

    where can I download this project example please?

  • @sanjeevkumarsingh2405
    @sanjeevkumarsingh2405 6 ปีที่แล้ว

    Great one which is focused on the topic.

  • @ryadboufar4741
    @ryadboufar4741 6 ปีที่แล้ว +1

    Awesome tutorial ! Thanks a lot

  • @UpDvn
    @UpDvn 3 ปีที่แล้ว

    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?

  • @td9082
    @td9082 6 ปีที่แล้ว

    Hello, Thanks for the great video. Why are the functions of Stopwatch that are called from QML not taged with Q_INVOCABLE?

  • @yahyasamet5499
    @yahyasamet5499 2 ปีที่แล้ว

    how i integrate a qml ApplicationWindow with qt application C++

  • @g4yktzgjx6
    @g4yktzgjx6 6 ปีที่แล้ว

    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?

    • @chombex
      @chombex 6 ปีที่แล้ว

      I think qml has visibility of c++ objects' Q_PROPERTY, public slots and Q_INVOKABLE

  • @sevketkarayilan
    @sevketkarayilan 5 ปีที่แล้ว

    where is this example full code?

  • @SATOSHI751
    @SATOSHI751 5 ปีที่แล้ว

    i don't have a 'Headers' folder in my project, what can i do ???

  • @EverythingEmbedded
    @EverythingEmbedded 4 ปีที่แล้ว

    Very useful. I love Qt

  • @Psy45Kai
    @Psy45Kai 6 ปีที่แล้ว +1

    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)

    • @QtStudios
      @QtStudios  6 ปีที่แล้ว +2

      Hi Kai, does something like this help? doc.qt.io/qt-5/qqmlcontext.html

  • @gupta2140
    @gupta2140 6 ปีที่แล้ว +1

    Great tutorial!

  • @bahadr4331
    @bahadr4331 6 ปีที่แล้ว +1

    Thank you for this video.

  • @mycollegeshirt
    @mycollegeshirt 6 ปีที่แล้ว

    absolutely amazing! yes!

  • @diegoperez-mu1dm
    @diegoperez-mu1dm 6 ปีที่แล้ว

    because they do not publish the source code of this program

  • @dineshlamarumba4557
    @dineshlamarumba4557 4 ปีที่แล้ว

    Code?

  • @iAnguel
    @iAnguel 5 ปีที่แล้ว

    Great! Now please show us how to do this properly for a TCP client including error handling

  • @matt_313
    @matt_313 3 ปีที่แล้ว

    3 years later... dozens of comments asking for the source... are you guys asleep over there at Qt?

  • @dalesmith8666
    @dalesmith8666 11 หลายเดือนก่อน +1

    Way to complicated!

  • @ironnoriboi
    @ironnoriboi ปีที่แล้ว

    Toogle!

  • @gloatsticks
    @gloatsticks 5 ปีที่แล้ว +1

    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.

    • @k4gcybex475
      @k4gcybex475 5 ปีที่แล้ว

      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.

    • @k4gcybex475
      @k4gcybex475 5 ปีที่แล้ว

      th-cam.com/video/JtyCM4BTbYo/w-d-xo.html

  • @lucianochatonildes2686
    @lucianochatonildes2686 6 ปีที่แล้ว +1

    Qwertu