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. Show Icon in table view without re-implementing model

Show Icon in table view without re-implementing model

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 2.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.
  • A Offline
    A Offline
    alizadeh91
    wrote on last edited by
    #1

    Hi,
    Is there any way to show an icon in table view cell without re-implementing model? can't it be done by using QStandardItemModel?
    Thanks

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mario84
      wrote on last edited by
      #2

      QStandardItem::setIcon() should work...

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

        Hi,

        It depends on what do you mean by reimplementing the model:
        Do you have a ready made model that you want to extend or do you want to avoid any model reimplementation ?

        Have a look at "QIdentityProxyModel":http://qt-project.org/doc/qt-4.8/qidentityproxymodel.html or "QStyledItemDelegate":http://qt-project.org/doc/qt-4.8/qstyleditemdelegate.html for two options

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

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

          Actually no, I just have a QStandardItemModel and i want to use it in a simple form so i don't want to do extra work!!! just easiest one! I know how to do that by re-implementing data method or how to do that by writing a delegate. Is it possible?
          Thanks :)

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

            In that case, use the suggestion from Mr.Universe, it's even simpler

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

            1 Reply Last reply
            0
            • francescmmF Offline
              francescmmF Offline
              francescmm
              wrote on last edited by
              #6

              It also be possible to show an icon (if it is the same for all rows) with a Delegate class.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alizadeh91
                wrote on last edited by
                #7

                Thanks all i got it :) (Special Thanks for Mr.Universe!!!)

                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