Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to stop color change from white to blue on click of qtable widget ?

How to stop color change from white to blue on click of qtable widget ?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
9 Posts 2 Posters 945 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by Qt embedded developer
    #1

    How to disable touch on q table widget . i want only use it for display data. i want to disable selection on it , disable change color of cell and disable multiple cell selection ?

    raven-worxR 1 Reply Last reply
    0
    • Q Qt embedded developer

      @raven-worx in above function which name I have to replace with ui->table.

      I am not getting how to use it with table widget can you tell me where I have to do changes

      For example replacing name with my table widget name , what extra thing I need to do

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #9

      @Qt-embedded-developer
      since you need to create a custom widget subclassed from QTableWidget and override a method from it you cant use the designer directly (unless you create a custom plugin for it)
      But you can add the widget on runtime into the layout. The layout is defined in the designer. Access the layout via the ui variable and call addWidget() on it.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Q Qt embedded developer

        How to disable touch on q table widget . i want only use it for display data. i want to disable selection on it , disable change color of cell and disable multiple cell selection ?

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @Qt-embedded-developer
        https://doc.qt.io/qt-5/qabstractitemview.html#selectionMode-prop

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        Q 2 Replies Last reply
        2
        • raven-worxR raven-worx

          @Qt-embedded-developer
          https://doc.qt.io/qt-5/qabstractitemview.html#selectionMode-prop

          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by
          #3

          @raven-worx though i use QAbstractItemView::NoSelection on selection white blue selection color comes how to stop it also

          1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Qt-embedded-developer
            https://doc.qt.io/qt-5/qabstractitemview.html#selectionMode-prop

            Q Offline
            Q Offline
            Qt embedded developer
            wrote on last edited by
            #4

            @raven-worx

            i have used below statement but it shows the light blue color on selection . i don't want this light blue color on selection

            ui->MAGNETOMETERtable_widget->setSelectionMode(QAbstractItemView::NoSelection);
            ui->MAGNETOMETERtable_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);

            raven-worxR 1 Reply Last reply
            0
            • Q Qt embedded developer

              @raven-worx

              i have used below statement but it shows the light blue color on selection . i don't want this light blue color on selection

              ui->MAGNETOMETERtable_widget->setSelectionMode(QAbstractItemView::NoSelection);
              ui->MAGNETOMETERtable_widget->setEditTriggers(QAbstractItemView::NoEditTriggers);

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #5

              @Qt-embedded-developer
              ok, i see.
              Alternatives are:

              Via the view:
              Subclass your item view and reimplement QAbstractItemView::selectionCommand() and always return QItemSelectionModel::NoUpdate in it.

              Via model:
              Create a custom QSortFilterProxyModel subclass and reimplement QSortFilterProxyModel::flags():

              Qt::ItemFlags NoSelectionModel::flags(const QModelIndex &index) const
              {
                  return QSortFilterProxyModel::flags(index) & ~Qt::ItemIsSelectable;
              }
              

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              Q 1 Reply Last reply
              1
              • raven-worxR raven-worx

                @Qt-embedded-developer
                ok, i see.
                Alternatives are:

                Via the view:
                Subclass your item view and reimplement QAbstractItemView::selectionCommand() and always return QItemSelectionModel::NoUpdate in it.

                Via model:
                Create a custom QSortFilterProxyModel subclass and reimplement QSortFilterProxyModel::flags():

                Qt::ItemFlags NoSelectionModel::flags(const QModelIndex &index) const
                {
                    return QSortFilterProxyModel::flags(index) & ~Qt::ItemIsSelectable;
                }
                
                Q Offline
                Q Offline
                Qt embedded developer
                wrote on last edited by Qt embedded developer
                #6

                @raven-worx said in How to stop color change from white to blue on click of qtable widget ?:

                QItemSelectionModel::NoUpdate

                can you provide example for
                how to subclass qtable widget ?

                how to reimplement QAbstractItemView::selectionCommand() ?

                raven-worxR 1 Reply Last reply
                0
                • Q Qt embedded developer

                  @raven-worx said in How to stop color change from white to blue on click of qtable widget ?:

                  QItemSelectionModel::NoUpdate

                  can you provide example for
                  how to subclass qtable widget ?

                  how to reimplement QAbstractItemView::selectionCommand() ?

                  raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by raven-worx
                  #7

                  @Qt-embedded-developer

                  QItemSelectionModel::SelectionFlags NoSelectionTable::selectionCommand(const QModelIndex &, const QEvent *)
                  {
                       return QItemSelectionModel::NoUpdate;
                  } 
                  

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  Q 1 Reply Last reply
                  0
                  • raven-worxR raven-worx

                    @Qt-embedded-developer

                    QItemSelectionModel::SelectionFlags NoSelectionTable::selectionCommand(const QModelIndex &, const QEvent *)
                    {
                         return QItemSelectionModel::NoUpdate;
                    } 
                    
                    Q Offline
                    Q Offline
                    Qt embedded developer
                    wrote on last edited by
                    #8

                    @raven-worx in above function which name I have to replace with ui->table.

                    I am not getting how to use it with table widget can you tell me where I have to do changes

                    For example replacing name with my table widget name , what extra thing I need to do

                    raven-worxR 1 Reply Last reply
                    0
                    • Q Qt embedded developer

                      @raven-worx in above function which name I have to replace with ui->table.

                      I am not getting how to use it with table widget can you tell me where I have to do changes

                      For example replacing name with my table widget name , what extra thing I need to do

                      raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #9

                      @Qt-embedded-developer
                      since you need to create a custom widget subclassed from QTableWidget and override a method from it you cant use the designer directly (unless you create a custom plugin for it)
                      But you can add the widget on runtime into the layout. The layout is defined in the designer. Access the layout via the ui variable and call addWidget() on it.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      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