[Qt-interest] Adding menu for tabwidget

Yuvaraj R yuvaraj at ongobiz.com
Thu Aug 20 13:06:57 CEST 2009


Raj sekar..

Already i have told... i have more  than 10 tabs , to reduce tab size, i am
using menu...

Here   i want to display only 2 tabs instead of 10 tabs.. remaining 8 tabs
will be displaying in menu..

Thanks

Yuvaraj R

On Thu, Aug 20, 2009 at 4:21 PM, rajasekharan <websweetweb at gmail.com> wrote:

> 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>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
>>
>
> ------------------------------
>
> _______________________________________________
> Qt-interest mailing listQt-interest at trolltech.comhttp://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/ec500c7c/attachment.html 


More information about the Qt-interest-old mailing list