[Qt-interest] Swapping out widgets?

Timothy Reaves treaves at silverfieldstech.com
Sun Dec 20 17:02:51 CET 2009


On Dec 20, 2009, at 11:00 AM, Sean Harmer wrote:

> 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 ).
> 

	Ah.  That looks just like the thing.  Thanks!



More information about the Qt-interest-old mailing list