PDA

View Full Version : Content not refreshed after QTabBar::moveTab()



clousque
25th February 2014, 16:16
Hi,

I have a class that inherits from QTabBar. Tabs in this tab bar may embed a window handler or a qml page. After I have moved a tab from left (index 0 for instance) to right (last index), the content of the moved tab (now at the last index) is in now the content of the tab at index 0 (after the move).

The move is done by QTabBar::moveTab().

tabbar->moveTab(tabbar->tabAt(m_dragStartPos), tabbar->tabAt (m_dragDropedPos));
So I thinked of a
setCurrentIndex(tabbar->tabAt (m_dragDropedPos)) but it did not work.

But when I do a removeTab(), addTab() and setCurrentIndex(), the result is good but the tab is always moved at the end of the TabBar.

Thanks for your help

ChrisW67
25th February 2014, 20:34
QTabBar does not have a content area, it is just a set of labelled tabs. It therefore cannot move any content you may have associated with the tab bar events: that is up to you. If you want that sort of behaviour QTabWidget is likely a better choice.

If you do not want the new tab to be the last in the bar then use insertTab()

clousque
26th February 2014, 09:12
Thanks for your reply,

It works, I misunderstood the use of QTabWidget and QTabBar. The move operation has to be done in QTabWidget.

Thanks again