[Qt-interest] Adding menu for tabwidget

rajasekharan websweetweb at gmail.com
Thu Aug 20 12:51:58 CEST 2009


Yuvraj,

Why do you want to implement the menu using a tab in a tabwidget?  I'm 
asking because users are not used to having menus pop up out of tabs 
generally, there may be a better, easier solution. Many users may not 
even know that the menu exists inspite of the downward arrow.

Kind Regards,
Raj Sekharan
http://www.expeditionpost.com

Yuvaraj R wrote:
> if i use like that ,while changing the tab ,menu wil show..
> Thanks
> Yuvaraj R
>
> On Thu, Aug 20, 2009 at 2:26 PM, Andre Somers <andre at familiesomers.nl 
> <mailto:andre at familiesomers.nl>> wrote:
>
>     Yuvaraj R wrote:
>     > Dear All
>     >
>     >
>     > I have near 10 tabs in my tab widget.. I don't like to display
>     the 10
>     > tabs in tabwidget..
>     >
>     > I want to provide menu for tabwidget..
>     >
>     > whenever user clciking the first tab ,menu will be display.
>     >
>     > Any ideas?
>     >
>     > how do we get the notification,suppose  first tab icon is pressed..
>     >
>     >
>     Not that hard, I guess. I did not try it myself, but I would go
>     about it
>     like this:
>
>     QTabWidget is internally using QTabBar.
>     Subclass your QTabWidget, and re-implement virtual bool
>     eventFilter(QObject*, QEvent*). Now,
>     install an eventfilter on the internal tabBar from your subclassed
>     QTabWidget's constructor by calling
>     tabBar()->installEventFilter(this).
>     Now, your eventFilter method will get all the events mend for the
>     tabBar.
>     In in the event filter, you listen for events mend from your
>     tabBar. You
>     will probably be interested in events of type
>     QEvent::MouseButtonPress.
>     If you find such an event, you can use QTabBar::tabAt() to find out on
>     which tab the user clicked. Return true from your eventFilter
>     implementation if you handled the event, and false if you don't (that
>     will be the majority of events!). If you forget this, your tabs
>     will not
>     do anything anymore.
>
>     To pop up a menu, simply populate a QMenu object and call it's popup
>     method. You can use the coordinates of the mouse press event to
>     position
>     your popup menu.
>
>     Something along those lines should work, I think.
>
>     André
>
>     _______________________________________________
>     Qt-interest mailing list
>     Qt-interest at trolltech.com <mailto:Qt-interest at trolltech.com>
>     http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>    

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090820/5e349d43/attachment.html 


More information about the Qt-interest-old mailing list