Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to repaint QWidget encapsulated in QDeclarativeItem in QML?
Forum Updated to NodeBB v4.3 + New Features

How to repaint QWidget encapsulated in QDeclarativeItem in QML?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qtquick 1.0qmlqt 4.8
25 Posts 2 Posters 14.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ChillaxC Chillax

    @p3c0 What's more interesting: If I call addFlow from QML, it works (replots). But if I call it from C++, it updates the QWidget, but not the QML Item. Even if I call refresh() from QML right after it, which should replot and repaint the QML Item too. Any explanation to this? Why is there a difference between changing the QWidget in the C++ code and asking for a replot from QML and doing everything in QML? As if the QML Item and the C++ QDeclarativeItem were two independent objects.

    So now my plan is to give the flow value from C++ to the FlowGrafik QML item, and then call addFlow from QML. That should work.

    p3c0P Offline
    p3c0P Offline
    p3c0
    Moderators
    wrote on last edited by
    #21

    @Chillax Unfortunately I too dont understand this behavior. The fact that it works in desktop environment and not on embedded only points that there should be some bug in that environment.

    So now my plan is to give the flow value from C++ to the FlowGrafik QML item, and then call addFlow from QML.

    Try. I had suggested the same earlier :)
    Let us know if it works or if possible the exact reason so that it may help others too.

    157

    ChillaxC 1 Reply Last reply
    1
    • p3c0P p3c0

      @Chillax Unfortunately I too dont understand this behavior. The fact that it works in desktop environment and not on embedded only points that there should be some bug in that environment.

      So now my plan is to give the flow value from C++ to the FlowGrafik QML item, and then call addFlow from QML.

      Try. I had suggested the same earlier :)
      Let us know if it works or if possible the exact reason so that it may help others too.

      ChillaxC Offline
      ChillaxC Offline
      Chillax
      wrote on last edited by
      #22

      @p3c0 So thanks a lot for the help! I would have given up without you :) The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.

      Now I created a pointer in the C++ code that points to the Item in the QML.

      QmlApplicationViewer flowView;
      flowView.setSource(QUrl("qrc:///qml/qml/FlowView.qml"));
      QObject * flowViewObject = flowView.rootObject();
      FlowGrafik * flowGrafik = flowViewObject->findChild<FlowGrafik *>(QString("FlowGrafik"));
      

      But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?

      p3c0P 1 Reply Last reply
      0
      • ChillaxC Chillax

        @p3c0 So thanks a lot for the help! I would have given up without you :) The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.

        Now I created a pointer in the C++ code that points to the Item in the QML.

        QmlApplicationViewer flowView;
        flowView.setSource(QUrl("qrc:///qml/qml/FlowView.qml"));
        QObject * flowViewObject = flowView.rootObject();
        FlowGrafik * flowGrafik = flowViewObject->findChild<FlowGrafik *>(QString("FlowGrafik"));
        

        But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?

        p3c0P Offline
        p3c0P Offline
        p3c0
        Moderators
        wrote on last edited by
        #23

        @Chillax Thank you :)

        The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.

        but now this makes me wonder as to why it worked on desktop.

        But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?

        Was the FlowGrafik object found ? You can add a small condition to verify it.

        if(flowGrafik) {
           flowGrafik->addFlow(...)
        }
        

        157

        ChillaxC 1 Reply Last reply
        1
        • p3c0P p3c0

          @Chillax Thank you :)

          The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.

          but now this makes me wonder as to why it worked on desktop.

          But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?

          Was the FlowGrafik object found ? You can add a small condition to verify it.

          if(flowGrafik) {
             flowGrafik->addFlow(...)
          }
          
          ChillaxC Offline
          ChillaxC Offline
          Chillax
          wrote on last edited by
          #24

          @p3c0 You are right, it was not found, because it was actually the rootobject, not a child :) Thanks again for the help!

          p3c0P 1 Reply Last reply
          0
          • ChillaxC Chillax

            @p3c0 You are right, it was not found, because it was actually the rootobject, not a child :) Thanks again for the help!

            p3c0P Offline
            p3c0P Offline
            p3c0
            Moderators
            wrote on last edited by
            #25

            @Chillax You're Welcome :)

            157

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved