This is something I used in my code, feel free to use and abuse. It does not handle double click, but it gives you a direction to your problem.
void qmdiTabBar
::mousePressEvent ( QMouseEvent * event
) {
if (event->button() == Qt::MidButton)
{
int tabCount = count();
for( int i=0; i<tabCount; i++ )
{
if (tabRect(i).contains(event->pos()))
{
emit middleMousePressed(i, event->pos());
break;
}
}
}
else if (event->button() == Qt::RightButton)
{
int tabCount = count();
for( int i=0; i<tabCount; i++ )
{
if (tabRect(i).contains(event->pos()))
{
emit rightMousePressed(i, event->pos());
break;
}
}
}
}
void qmdiTabBar::mousePressEvent ( QMouseEvent * event )
{
if (event->button() == Qt::MidButton)
{
int tabCount = count();
for( int i=0; i<tabCount; i++ )
{
if (tabRect(i).contains(event->pos()))
{
emit middleMousePressed(i, event->pos());
break;
}
}
}
else if (event->button() == Qt::RightButton)
{
int tabCount = count();
for( int i=0; i<tabCount; i++ )
{
if (tabRect(i).contains(event->pos()))
{
emit rightMousePressed(i, event->pos());
break;
}
}
}
QTabBar::mousePressEvent(event);
}
To copy to clipboard, switch view to plain text mode
Bookmarks