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 bind signal of item in QAbstractListModel to handler in delegate of ListView

How to bind signal of item in QAbstractListModel to handler in delegate of ListView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlbindingqabstractlistmolistview
11 Posts 2 Posters 4.5k Views
  • 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.
  • R Offline
    R Offline
    ribtoks
    wrote on last edited by ribtoks
    #1

    I have a QAbstractListModel descendant class with list of instances of my arbitrary type MyItem inside. Also I have a ListView with model binding to that QAbstractListModel descendant.

    All I want to do is to bind handler in delegate of ListView to the signal of my arbitrary type MyItem. Is there any way to do it?

    UPD. I don't want to bind delegate to signal of a model so when I will have many items all of them will be triggered. I want to notify only one delegate with a signal.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What do you want to happen with this signal to the delegate ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      R 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What do you want to happen with this signal to the delegate ?

        R Offline
        R Offline
        ribtoks
        wrote on last edited by
        #3

        @SGaist I want to call deselect() on the TextEdit which lives in the delegate. It's the only workaround I found for my issue (to make TextEdit rehighlight itself) from parallel topic https://forum.qt.io/topic/61223/unable-to-get-highlighting-working-on-textedit.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What are you highlighting ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          R 1 Reply Last reply
          0
          • SGaistS SGaist

            What are you highlighting ?

            R Offline
            R Offline
            ribtoks
            wrote on last edited by
            #5

            @SGaist Just spell errors in red.

            After spell-checking is done in separate thread, main model is being notified about results, which are propagated to class, which is accessible through my QSyntaxHighlighter descendant. Then the signal which is connected to rehighlight() is fired. I debugged that rehighligh() is executed, setFormat() is executed as well with correct parameters, but no real highlighting is painted until I interact with the control itself.

            I found that calling any method of TextEdit which does nothing in my situation (like deselect()) will cause highlighting to be drawn, so I want to get to that method somehow through signal. I just don't want to fire signal for all items in the model.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Can you post a small code sample that helps reproduce this behavior ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              R 1 Reply Last reply
              0
              • SGaistS SGaist

                Can you post a small code sample that helps reproduce this behavior ?

                R Offline
                R Offline
                ribtoks
                wrote on last edited by ribtoks
                #7

                @SGaist https://bitbucket.org/ribtoks/rehighlighdemo/src It's very basic (item, main model, worker, highlighter - everything I had), working example similar to my setup. Highlighting works if you click on a TextEdit, but doesn't otherwise.
                If you will bother building and running it, click on "Check highlighting" and then on any text field. Also you can notice debug messages about highlighting being applied, but not redrawn.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  It seems it's working on OS X with Qt 5.6

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  R 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    It seems it's working on OS X with Qt 5.6

                    R Offline
                    R Offline
                    ribtoks
                    wrote on last edited by
                    #9

                    @SGaist It's interesting that someone reported at StackOverflow that my test project did work for him in Qt 5.5.1 (I was using 5.4.2 at that moment), but when I upgraded, my main application still didn't work, though it has same code, but a lot of more stuff in main model.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Which OS are you on ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      R 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Which OS are you on ?

                        R Offline
                        R Offline
                        ribtoks
                        wrote on last edited by
                        #11

                        @SGaist OS X 10.10 and Win 10

                        1 Reply Last reply
                        0

                        • Login

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