Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Further "Plumbing" for Model->View->Delegate...
QtWS25 Last Chance

Further "Plumbing" for Model->View->Delegate...

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 3.2k 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
    ronM71
    wrote on last edited by
    #1

    I have a QListView, clearly showing, My model is full of data. My model's ::rowCount() is called and returns a > 0 result. I connected my model to the QListView with "setModel". I connected the delegate to the QListView with "setItemDelegate".

    Yet the "Paint" method on my delegate isn't called, not once. Not even after resizing the live QListView. Why?

    Do I need further "hooking up" of events here? perhaps connecting some slots to signals? I thought the "setModel" and "setDelegate" will take care of that for me. Was I wrong?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      no, normally it works
      please show us some example code which does not work.
      I'm sure, there is some bug in :-)
      I use model view delegate a lot and it works

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on last edited by
        #3

        I got it.

        I wasn't signaling of a model update using the model's "begin/end" method pairs. I was adding content to the model using my own methods so the model really could not notify the listView there's content to view which of course resulted in no painting.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Check if you got the method signature exactly right. It is quite easy to forget the const, for instance.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ronM71
            wrote on last edited by
            #5

            QT-Creator uses a compiler that screams about signatures, namely the const at the end.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              If you type the function signatures yourself, Qt Creator allows you to forget the const just fine. :-)

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

                Then you have two functions, one const and one not...
                gives nice error prone behavior...

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  My point was, that if you think you have reimplemented a virtual function like paintEvent, but you forgot the const at the end, you can wait for along time for it to get called :-) Your application will simply use the version in the baseclass you subclassed.

                  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