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 cellwidget set invisible become visible after column resize

QTableWidget cellwidget set invisible become visible after column resize

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.0k 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.
  • H Offline
    H Offline
    hbatalha
    wrote on last edited by
    #1

    I have a QTableWidget where I have cells that contain a QPushButton and at some point I won't need those buttons anymore so instead of removing (removeCellWidget) I decided to just make them invisible. However, after I do it, if that cell size ever changes, during a window resize for example, the buttons recently setVisible(false) become visible again.

    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
        , ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        ui->table->setRowCount(1);
    
        QPushButton *p = new QPushButton("Test");
    
        ui->table->setCellWidget(0, 0, p);
    
        connect(p, &QPushButton::clicked, [p]()
        {
            p->setVisible(false);
        });
    
    }
    

    With this minimum working example, after clicking the button it becomes invisible but if you resize the column or row it becomes visible again.

    Is it meant to behave like this?

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

      Hi,

      Which version of Qt are you using ?
      On which platform ?

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

      H 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Which version of Qt are you using ?
        On which platform ?

        H Offline
        H Offline
        hbatalha
        wrote on last edited by
        #3

        @SGaist Qt 6.0.1
        Both Linux and Windows.

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

          Can you check with Qt 5.15 ?

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

          H 1 Reply Last reply
          0
          • SGaistS SGaist

            Can you check with Qt 5.15 ?

            H Offline
            H Offline
            hbatalha
            wrote on last edited by
            #5

            @SGaist Just tested, same results

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

              While it might seem surprising, I would say it's not unexpected. The goal of setWidget is to show static content so handling its visibility is likely not something that has been implemented.

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

              H 1 Reply Last reply
              1
              • SGaistS SGaist

                While it might seem surprising, I would say it's not unexpected. The goal of setWidget is to show static content so handling its visibility is likely not something that has been implemented.

                H Offline
                H Offline
                hbatalha
                wrote on last edited by
                #7

                @SGaist I would say it is not right though, it is very counter-intuitive and there is nothing about this in the doc that I could find. Thank you for the explanation.

                So to solve my problem I had to remove the cellWidget.

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

                  One thing you can do is to check the bug report system. If there's nothing there, you can consider opening a new ticket providing a minimal compilable example.

                  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
                  • H hbatalha

                    @SGaist I would say it is not right though, it is very counter-intuitive and there is nothing about this in the doc that I could find. Thank you for the explanation.

                    So to solve my problem I had to remove the cellWidget.

                    H Offline
                    H Offline
                    hbatalha
                    wrote on last edited by
                    #9

                    @hbatalha Done, https://bugreports.qt.io/browse/QTBUG-92573

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

                      Dupe of https://bugreports.qt.io/browse/QTBUG-13522 - don't use widgets in itemviews. We really should have deprecate this widget inside item views stuff in Qt6...

                      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
                      1

                      • Login

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