Details
-
Bug
-
Resolution: Fixed
-
P4: Low
-
6.6.2
-
None
-
-
0f9062ec7 (dev), 3c0f08ab7 (6.9), f70803eef (6.8), 618a2050d (tqtc/lts-6.5)
Description
InsertWidget on a layout results in a segfault if index is too big. Minimal example:
#include <QtWidgets> class MyDialog : public QDialog { public: MyDialog(QWidget *parent = nullptr) : QDialog(parent) { QVBoxLayout *layout_1 = new QVBoxLayout(this); layout_1->insertWidget(1, new QLabel("aaa", this)); } }; int main(int argc, char *argv[]) { QApplication qt_app(argc, argv); MyDialog window; window.show(); return qt_app.exec(); }
It works correctly if index is 0. This is confusing, as documentation says: "Inserts widget at position index, with stretch factor stretch and alignment alignment. If index is negative, the widget is added at the end." , which does not suggest any restrictions on index. I think a segfault is a very ugly way of handling it, some sort of more descriptive error would make debugging much easier.