[Qt-interest] Adding menu for tabwidget

Yuvaraj R yuvaraj at ongobiz.com
Thu Aug 20 12:33:13 CEST 2009


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>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
> 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/240f9bff/attachment.html 


More information about the Qt-interest-old mailing list