PDA

View Full Version : Context menu on tab



wolfi3b
17th October 2010, 12:11
Hi,
Im working with tab widget, and I am trying to implement context menu on this widget. What I want to do is, if I right click on upper part,hmm, not sure about right english word, so here is picture of what I mean
http://lh5.ggpht.com/_BoJz15FOeMM/TLrXjLrWxcI/AAAAAAAAABs/gL_SdaYZBkA/s144/tab.jpg

So there are two tabs
-Clipboard
-Tab0
-....etc

I need to know if I right-click on clipboard, tab0 or what ever tab i click on if there are more of them. I know how to find which tab is up(In this picture Tab0), I think I know how to find if I clicked on tab widget or some another widget, but Im not sure how to find on which tab hmm..stil not sure about name,you know, the part shown on the picture. Can please anyone direct me on the right track?
Thx

wysota
17th October 2010, 14:14
Use QTabWidget::tabBar() to query for its tab bar. Set its context menu policy to custom and connect its customContextMenuRequested(QPoint) signal to a slot of yours. Then use QTabBar::tabAt() to map the point you get to the tab index and show a menu.

wolfi3b
18th October 2010, 17:35
Thx :-) Helped a lot :-)