Hi,
so what i want to do is basically to make my QTabWidget able to respond to right mouse button event as if it was a left button and ALSO a right button; tab bar should both set clicked widget as current and exec context menu. The problem is that I have no idea how to achieve that.
I tried to redefine mousePressEvent as you can see in the example below (code is in Ruby, I hope that's not a problem, but if so I can try to translate it to C++).
class MainTab < Qt::TabWidget
def mousePressEvent(event)
if event.button == Qt::RightButton
newEvent = Qt::MouseEvent.new(Qt::Event::MouseButtonPress, event.pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)
mousePressEvent(newEvent)
end
end
end
class MainTab < Qt::TabWidget
def mousePressEvent(event)
if event.button == Qt::RightButton
newEvent = Qt::MouseEvent.new(Qt::Event::MouseButtonPress, event.pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)
mousePressEvent(newEvent)
end
end
end
To copy to clipboard, switch view to plain text mode
Of course it doesn't work, and I am totally clueless what to do now. So I was hoping you could give me some hints.
Bookmarks