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

QTabWidget insertTab() changes inserted widget's parent

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P4: Low
    • None
    • 5.6.3
    • None
    • Windows

    Description

      Code :

      void test()

      {   QMainWindow *mw = new QMainWindow();   QTabWidget *tabwidget = new QTabWidget(mw);   QLabel *label = new QLabel(mw);   tabwidget->insertTab(0, label, "Some title"); QWidget *w = tabwidget->widget(0);   qDebug()<<"CLASS NAME :"<<w->parent()->metaObject()->className();   qDebug()<<"OBJECT NAME :"<<w->parent()->objectName(); }

      expected result : 
      CLASS NAME : QMainWindow
      OBJECT NAME : "mw"

      actual result :

      CLASS NAME : QStackedWidget
      OBJECT NAME : "qt_tabwidget_stackedwidget"
       
      Offical documentation says :

      int QTabWidget::insertTab(int index, QWidget* page, const QString & label)

      Inserts a tab with the given label and page into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. Ownership of page is passed on to the QTabWidget.

      1. Is 'Ownership of page ' means 'Parentship of page' too? 

      2. If yes, why QStackedWidget and not  QTabWidget ?

      Attachments

        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
            delphi251189 Karapet Khachoyan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes