PDA

View Full Version : QTabWidget problem



Strongoloid
10th September 2009, 17:37
Hello,

I have a QTabWidget with other stuff that I put together using Designer. Each tab contains some visual elements like QTreeViews, etc. In Designer, I've set the tab position to be South, and the tabs appear at the bottom as they should.

However, I wanted some custom behavior during drag/drop events, so I subclassed QTabWidget. My problem is in using the tabAt function in QTabBar (namely in calls in the QTabWidget subclass such as tabBar()->tabAt(event->pos())). The function returns -1 (indicating no tab under the cursor) even though the cursor is over a tab, but it will return the proper tab index when the cursor is over where the tab would be if the tab position was North (sorry for the confusing wording).

In other words, it seems like something is wrong in that it believes the tabs are still in the North position, even though they are in the South position. Any suggestions?

bunjee
10th September 2009, 20:04
Hi, can we see some code?

Strongoloid
10th September 2009, 20:38
void OutputTabWidget::dragMoveEvent(QDragMoveEvent* event)
{
qDebug("tab under mouse is %i", tabBar()->tabAt(event->pos()));
}


OutputTabWidget is a subclass of QTabWidget. The UI work was done in Designer (if you want me to post the code it generated I can), which would be where the TabPosition is set to South, mouseTracking is set to true, etc.

The debug output spits out the correct indexes for the tab under the cursor (during the drag) if the tabs are in the North position (if I change it in Designer).