[Qt-interest] Swapping out widgets?

Sean Harmer sean.harmer at maps-technology.com
Sun Dec 20 17:00:10 CET 2009


Hi,

On Sunday 20 December 2009 14:46:20 Timothy Reaves wrote:
> 	I'm wanting a UI where I have some buttons on the left, and a frame on 
the
>  right.  When a use clicks on one of the buttons, I'd like to replace the
>  frame on the rights content with a different widget.  I understand the
>  wiring, but I can't figure out how to swap contents.  QFrame has an
>  addChild method, but no remove, and no replace.  What is the correct way
>  to do this?  Unfortunately I can not use tabs, as the window is fairly
>  small, and the tabs text too large (and I'm no good at icons!).

Try using QStackedWidget. This is similar in concept to a tabbed widget but 
you control which widget on the stack is visible by some other means i.e. 
connecting some signal(s) up to setCurrentIndex( int ).

HTH,

Sean



More information about the Qt-interest-old mailing list