[Qt-interest] How add a QTreeView widget to a QTabBar?

rajasekharan websweetweb at gmail.com
Tue Jul 28 09:06:21 CEST 2009


Ed,

I assume you want to add a tab in the QTabBar in which the QTreeView 
will be shown when that tab is clicked? If so..

QTabBar provides only a bar with tabs on it and doesn't enclose any 
other widgets inside it. So if you want to use
a tab interface where each tab encloses other widgets, you must use 
QTabWidget. So your code will be like this:

modelGoodDevices = new DomModel(QDomDocument(), this);

thetabs = new QTabWidget(this);

viewGoodDevices = new QTreeView(this);

thetabs->addTab(viewGoodDevices,"Good Devices");

Alternatively you may use a QTabBar for accomplishing the exact same but 
you must do it conjunction with QStackedWidget
or QStackedLayout. In these two, you can add some widgets to them but 
only one will be visible.You can use the void currentChanged(int index)
signal emitted by the QTabBar when a tab is clicked to switch the 
QStackWidget/QStackLayout to the
appropriate widget.

With Regards,
Raja Sekharan
http://www.expeditionpost.com


Ed Sutton wrote:
>
> How do I add a QTreeView to a tab on a QTabBar ?
>
> modelGoodDevices = new DomModel(QDomDocument(), this);
>
> qtabBar = new QTabBar(this);
>
> viewGoodDevices = new QTreeView(this);
>
> qtabBar->addTab("Good Devices");
>
> qtabBar->addTab("Failed Devices");
>
> // How do I add viewGoodDevices to the "Good Devices" tab?
>
> Thanks in advance,
>
> -Ed
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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/20090728/fe030004/attachment.html 


More information about the Qt-interest-old mailing list