Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-13522

setvisible() of QWidget has no effect at QTreeWidgetItem

    XMLWordPrintable

Details

    • 04de24c6449422d29a0d4760375aa94f59222fa3, Revert: dd262dc7f5c02ffaaa965815a9ccc8978efdbabf

    Description

      I think there is a bug at QTreeWidgetItem.

      In this sample project I added a QTreeWidget item with a button and text.

      After this I set the following line:

      pbtn->setVisible(false);
      
      

      Here I expected that the button is displayed and only the text below is shown after but it isn't. The button is displayed all the time so the method "setVisible()" has no effect. I attached the sample project.

      mainwindow.h:

      #include <QMainWindow>
      
      #include <QTreeWidget>
      #include <QTreeWidgetItem>
      #include <QPushButton>
      
      
      namespace Ui {
          class MainWindow;
      }
      
      class MainWindow : public QMainWindow {
          Q_OBJECT
      public:
          MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      protected:
      		void changeEvent(QEvent *e);
      
      private:
          Ui::MainWindow *ui;
      
      	private slots:
      		void click123();
      };
      

      mainwindow.cpp:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
      		QTreeWidgetItem *widget_item;
      
      		widget_item = new QTreeWidgetItem();
      		widget_item->setText(0, "example text");
      
      		QPushButton *pbtn;
      
      		pbtn = new QPushButton();
      		pbtn->setText("example");
      		pbtn->setVisible(false);
      
      		ui->treeWidget->addTopLevelItem(widget_item);
      
      		ui->treeWidget->setItemWidget(widget_item, 0, pbtn);
      
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::changeEvent(QEvent *e)
      {
          QMainWindow::changeEvent(e);
          switch (e->type()) {
          case QEvent::LanguageChange:
              ui->retranslateUi(this);
              break;
          default:
              break;
          }
      }
      
      void MainWindow::click123() {
      
      
      }
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              anno Hans Müller
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated: