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. QTableWidget: Cells updating event
Qt 6.11 is out! See what's new in the release blog

QTableWidget: Cells updating event

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 796 Views 2 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.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by
    #1

    Hi!
    Is there some mechanism like 'OnDrawCell' from C++Builder/RAD Studio?
    In that method, there is work with Canvas, I could dynamically change Color, Text, etc of any cell, even the header cell. I just want to create a simple code for any cell.
    Thank you!

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      If you want to modify the displaying of a cell you can either return e.g. a different color for e.g. BackgroundRole or similar or use a custom QStyledItemDelegate to draw the content by yourself.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      3
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi
        A full blown OnDrawCell like CB would be a delegate however, you can
        change color, font with Roles without resorting to custom drawing.

        sitesvS 1 Reply Last reply
        3
        • mrjjM mrjj

          Hi
          A full blown OnDrawCell like CB would be a delegate however, you can
          change color, font with Roles without resorting to custom drawing.

          sitesvS Offline
          sitesvS Offline
          sitesv
          wrote on last edited by
          #4

          @mrjj said in QTableWidget: Cells updating event:

          Hi
          A full blown OnDrawCell like CB would be a delegate however, you can
          change color, font with Roles without resorting to custom drawing.

          Hi!
          Is it possible to dynamically draw inside cells something like colored figures: square, rectangle, etc?

          mrjjM 1 Reply Last reply
          0
          • sitesvS sitesv

            @mrjj said in QTableWidget: Cells updating event:

            Hi
            A full blown OnDrawCell like CB would be a delegate however, you can
            change color, font with Roles without resorting to custom drawing.

            Hi!
            Is it possible to dynamically draw inside cells something like colored figures: square, rectangle, etc?

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @sitesv
            Hi
            Yes, that would be a job for a delegate.
            here is a sample where its a rating box
            https://doc.qt.io/qt-5/qtwidgets-itemviews-stardelegate-example.html

            but it could draw anything.

            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