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

QHeaderView::ResizeToContents causes crash when editing long items

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P1: Critical P1: Critical
    • None
    • 6.3.1
    • None
    • Windows 10 21H2
    • Windows

      Application crashes when an editing is triggered for an long item and the right border of editor is outside of the view.

       

       

      Here's the complete demo to produce:

      1. Run this program
      2. Double click the first item
      3. See the crash

      There're some ways to "avoid" the crash:

      1. Scroll to the right before double clicking, or
      2. Remove the second item, or
      3. Resize the window so that the entire editor can be shown, or
      4. Don't set ResizeToContents mode
      #include <QDebug>
      #include <QApplication>
      #include <QWidget>
      #include <QVBoxLayout>
      #include <QTreeView>
      #include <QPushButton>
      #include <QHeaderView>
      #include <QStandardItem>
      #include <QStandardItemModel>
      
      int main(int argc, char** argv) {
          QApplication app(argc, argv);
      
          auto widget = new QWidget;
          auto box = new QVBoxLayout(widget);
          auto model = new QStandardItemModel(widget);
          model->appendRow(QList{
                               new QStandardItem("Double Click Me! Double Click Me! Double Click Me! Double Click Me!"),
                               new QStandardItem("test"), // comment this line to avoid crash
                           });
          auto tree = new QTreeView(widget);
          box->addWidget(tree);
          tree->setModel(model);
          tree->header()->setSectionResizeMode(QHeaderView::ResizeMode::ResizeToContents);    widget->show();
      
          return app.exec();
      
      }
      

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

            vhilshei Volker Hilsheimer
            namniav vainman H
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes