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. Visual hint in table view that item is editable?
Forum Updated to NodeBB v4.3 + New Features

Visual hint in table view that item is editable?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 3 Posters 702 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by
    #1

    Certain cells in my table view are editable, but there's no visual hint in the way the information is displayed to tell the user that those cells are editable. What's the simplest clean/elegant way (assuming the use of the default QStyledItemDelegate) to provide this information to the user?

    Unsetting flag Qt::ItemIsEnabled for the non-editable cells isn't appropriate for this case.

    David

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

      Hi,

      You could highlight the background of your editable cells with a different color.

      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
      • AndyBriceA Offline
        AndyBriceA Offline
        AndyBrice
        wrote on last edited by
        #3

        Make the non-editable cells a mid grey?

        1 Reply Last reply
        0
        • PerdrixP Offline
          PerdrixP Offline
          Perdrix
          wrote on last edited by
          #4

          I was thinking of something similar to the light blue background shown here AFTER the cell has been edited ( I think it's a Gradient Brush). Strangely it's the same as all the other cells before it is edited???

          583dc944-14dd-4f8f-8c6c-8382245b8f99-image.png

          How would I achieve something like that without writing my own Style sub-class.
          Ideally using a Brush the Style would use rather than a single arbitrary solid colour or Gradient brush that I hard code.

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

            How do you know which cell can be edited and which not ?

            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
            • PerdrixP Offline
              PerdrixP Offline
              Perdrix
              wrote on last edited by
              #6

              QAbstractTableModel::flags()

                  inline Qt::ItemFlags flags(const QModelIndex& index) const override
                  {
                      auto flags = Inherited::flags(index);
                      switch (Column(index.column()))
                      {
                      case Column::Path:
                          flags |= (Qt::ItemIsUserCheckable);
                          break;
                      case Column::Type:
                      case Column::ISO:
                      case Column::Exposure:
                          flags |= (Qt::ItemIsEditable);
                          break;
                      }
                      return flags;
                  }
              
              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You can return a custom value for the Qt::BackgroundRole.

                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
                1
                • PerdrixP Offline
                  PerdrixP Offline
                  Perdrix
                  wrote on last edited by
                  #8

                  I'm aware of that - what I want to do is to use a Brush for that comes from the current Style (e.g. Fusion), rather than creating my own.

                  I showed two examples earlier in the thread that would have done well which were clearly chosen by the Style when the cell was rendered - all I want to do is pick one of those up.

                  1 Reply Last reply
                  0
                  • PerdrixP Offline
                    PerdrixP Offline
                    Perdrix
                    wrote on last edited by
                    #9

                    OH! I only showed one! This is the other one:

                    e9991552-c8ce-4480-88ce-0112c49a0bbb-image.png

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

                      You can grab the QPalette from the style and get the color you want from it.

                      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
                      1

                      • Login

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