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

QStyleItemDelegate

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 757 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.
  • J Offline
    J Offline
    juaniyoalm
    wrote on last edited by
    #1

    I need to create a project in which there is a QTableView that contains cell with some drawings, these drawings have to change size at run time when the variables of the model change. I have seen that I can use QStyleItemDelegate but I do not know how to use it. I do not know what methods I need to overwrite, since I do not want to edit the cells manually, only to have them repaint when the model data changes. In each cell I need to show a circle that changes size according to the data of the model. I need your help please.

    K 1 Reply Last reply
    0
    • J juaniyoalm

      I need to create a project in which there is a QTableView that contains cell with some drawings, these drawings have to change size at run time when the variables of the model change. I have seen that I can use QStyleItemDelegate but I do not know how to use it. I do not know what methods I need to overwrite, since I do not want to edit the cells manually, only to have them repaint when the model data changes. In each cell I need to show a circle that changes size according to the data of the model. I need your help please.

      K Offline
      K Offline
      kenchan
      wrote on last edited by
      #2

      @juaniyoalm
      When I do that I make a QStyleItemDelegate and just override the paint and sizeHint methods.
      There may be an easier way to do it but I don't know what it is. Someone else might suggest an easier way though.

      1 Reply Last reply
      2
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        Did you see the examples in Qt installation example directory ?

        widgets/itemviews/spinboxdelegate/delegate.cpp:  
        widgets/itemviews/stardelegate/stardelegate.cpp:
        

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        1
        • J Offline
          J Offline
          juaniyoalm
          wrote on last edited by
          #4

          This examples aren't wright for me. I wanna redrawing cell, not edit.

          VRoninV K 2 Replies Last reply
          0
          • J juaniyoalm

            This examples aren't wright for me. I wanna redrawing cell, not edit.

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @juaniyoalm said in QStyleItemDelegate:

            This examples aren't wright for me

            They are. Strardelegate in particular. @mrjj gave you a working example of your solution already: https://forum.qt.io/topic/96545/insert-fill-circle-into-cell-of-qtablewidget

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            4
            • J juaniyoalm

              This examples aren't wright for me. I wanna redrawing cell, not edit.

              K Offline
              K Offline
              kenchan
              wrote on last edited by kenchan
              #6

              @juaniyoalm
              Like I said, just override the paint and sizeHint functions and you can do what you want.

              1 Reply Last reply
              2

              • Login

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