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. setColumnHidden() not working for cell widget ?
Forum Updated to NodeBB v4.3 + New Features

setColumnHidden() not working for cell widget ?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 5 Posters 517 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.
  • I Offline
    I Offline
    iw2lsi
    wrote on last edited by
    #1

    Hi all,

    I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...

    Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?

    thanks a lot,
    
           Giampaolo
    
    JonBJ JoeCFDJ 2 Replies Last reply
    0
    • I iw2lsi

      Hi all,

      I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...

      Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?

      thanks a lot,
      
             Giampaolo
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @iw2lsi said in setColumnHidden() not working for cell widget ?:

      is this an expected behaviour ?

      Not so far as I know, no. I would expect it not to show the column whether it has cell widgets or not.

      1 Reply Last reply
      0
      • I iw2lsi

        Hi all,

        I have a QTableWidget populated with many rows and colums... some columns are made of standard QTableWidgetItem(), others are populated using setCellWidget()...

        Everything works as expected until I try to dynamically show/hide some colums using setColumnHidden()... which seems to work only for standard columns but not for colums that contains widgets (comboBoxex in my case)... is this an expected behaviour ?

        thanks a lot,
        
               Giampaolo
        
        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @iw2lsi Qt version and OS?

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

          Hi,

          I am not quite surprised as setCellWidget should be used only to show some static content. If you need better integration, you should implement a custom QStyledItemDelegate.

          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
          • ThirdStrandT Offline
            ThirdStrandT Offline
            ThirdStrand
            wrote on last edited by
            #5

            73 Giampaolo,

            As a fallback, you could enable/disable the UI controls (combo boxes). They would still be visible but blocked from end user usage.

            I have always found the QTableWidget and QListWidget helpful for simple textual displays, but anything more complicated and I switch to QTableView and manage the model separately. This also makes the QDataWidgetMapper available which is a fun toy. I use that with message content display when the user clicks on a table row (like an email client might use).

            Mitch
            ab4mw

            1 Reply Last reply
            0
            • I Offline
              I Offline
              iw2lsi
              wrote on last edited by iw2lsi
              #6

              Hi all and thanks for the support...

              I confirm that setColumnHidden() does not work for cells containing widgets... below is an extract of my table:

              tableWidget.png

              what I'm trying to achieve is to hide some columns according to the user level (admin, supervisor, operator etc) to simplify the table for non-expert users... I'm already disabling some cells according to the selected type/contents but in this case I would like to hide completely some columns like type, order & size...

              I know I can switch to QTableView but in this case, as the expected number of rows is low, I prefer to stay on a QTableWidget if possible...

              BTW: I'm using Windows11 with QT6.4.2

              I'll investigate it deeply today...

                            thanks again and Best Regards 
              
                                         Giampaolo
              
              1 Reply Last reply
              0
              • I Offline
                I Offline
                iw2lsi
                wrote on last edited by
                #7

                Hi all,

                while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets... I'll be back as soon as I got more info... sorry for the false-report.

                   Giampaolo
                
                JonBJ 1 Reply Last reply
                0
                • I iw2lsi

                  Hi all,

                  while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets... I'll be back as soon as I got more info... sorry for the false-report.

                     Giampaolo
                  
                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @iw2lsi said in setColumnHidden() not working for cell widget ?:

                  while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets...

                  Which is what I suggested :) Which is why one should always prepare a minimal example illustrating a problem...!

                  I 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @iw2lsi said in setColumnHidden() not working for cell widget ?:

                    while preparing a minimal piece of code to reproduce the behaviour, I found that setColumnHidden() seems to work even on columns made of widgets...

                    Which is what I suggested :) Which is why one should always prepare a minimal example illustrating a problem...!

                    I Offline
                    I Offline
                    iw2lsi
                    wrote on last edited by
                    #9

                    @JonB yes... you are right... my fault...

                    1 Reply Last reply
                    0
                    • I iw2lsi has marked this topic as solved on

                    • Login

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