Hi Graham, Have you tried forcing a Qt::QueuedConnection for the connect calls? That way the QTabBar has a higher chance of being set up completely before the slot is run.
Greets, Ben > -----Original Message----- > From: interest-bounces+benswerts=telenet...@qt-project.org > [mailto:interest-bounces+benswerts=telenet...@qt-project.org] On Behalf > Of Graham Labdon > Sent: Friday, July 25, 2014 11:32 > To: Paul Miller; interest@qt-project.org > Subject: Re: [Interest] Tabbed Dock Widgets > > Ok I can now demonstrate my problem - > In my class I have > TabWidgetTest::TabWidgetTest(QWidget *parent) > : QMainWindow(parent) > { > ui.setupUi(this); > > m_dockWidgets.append(new QDockWidget("Dock 1",this)); > m_dockWidgets.last()->setWidget(new Dock1Content(this)); > addDockWidget(Qt::BottomDockWidgetArea,m_dockWidgets.last()); > m_dockWidgets.last()- > >setAllowedAreas(Qt::BottomDockWidgetArea); > > m_action1 = m_dockWidgets.last()->toggleViewAction(); > m_action1->setData(0); > connect(m_action1,&QAction::toggled,this,&TabWidgetTest::onView > Toggled); > > m_dockWidgets.append(new QDockWidget("Dock 2",this)); > m_dockWidgets.last()->setWidget(new Dock2Content(this)); > addDockWidget(Qt::BottomDockWidgetArea,m_dockWidgets.last()); > m_dockWidgets.last()- > >setAllowedAreas(Qt::BottomDockWidgetArea); > > m_action2 = m_dockWidgets.last()->toggleViewAction(); > m_action2->setData(1); > connect(m_action2,&QAction::toggled,this,&TabWidgetTest::onView > Toggled); > > tabifyDockWidget(m_dockWidgets[0],m_dockWidgets[1]); > } > > In the slot I have > { > QList<QTabBar*> tabBarList = findChildren<QTabBar*>(); > QTabBar* tabBar = NULL; > if (!tabBarList.isEmpty()) > { > tabBar = tabBarList.at(0); > qDebug() << "Count = " << tabBar->count(); > } > else > { > qDebug() << "No tab bar"; > } > > QAction* action = dynamic_cast<QAction*>(sender()); > > if (action) > { > int data = action->data().toInt(); > qDebug() << checked << " " << data; > } > qDebug() << ""; > // m_dockWidgets[data]->raise(); > //} > } > > When the slot is called the tabbed widget that is to be added has not yet > been added to the tab bar. and I cannot see a way of catching when a widget > has been added to the tab bar. > > Is there a way in which this can be achieved? > > Thanks _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest