1

How do I switch between the two screens on the Qt?

For example, I have a button - static text plus a toolbar. Now I will add it to a frame and set it as a central widget. It works well for one window.

What if I move it to the next window? Then I need to show some other stuff like another button, some images etc... and what if I come back to the first view again?

How do I show my old widgets back?

JavaAndCSharp
  • 1,507
  • 3
  • 23
  • 47
Naruto
  • 9,476
  • 37
  • 118
  • 201

2 Answers2

1

I'm not sure I got your problem right but, you could have different scenarios :

  1. You could simply use groupboxes... Some widgets in groupbox1, otherWidget in groupbox2, and you display the groupbox you want to use, hiding the others...

  2. You could use stackedWidget, which simulates "pages" of widgets stacked on top of eachothers... more informations here : http://qt.nokia.com/doc/4.6/qstackedwidget.html.

  3. You could use other way like using tabs : http://doc.trolltech.com/4.6/qtabwidget.html

  4. Maybe this example would be useful to you : http://qt.nokia.com/doc/4.6/dialogs-configdialog.html

Hope it helps a bit !

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Andy M
  • 5,945
  • 7
  • 51
  • 96
  • Ok andy.. fine.. Thanks.. how about updating the menu dynamically when i moves to different views? – Naruto Mar 11 '10 at 07:11
  • You could have multiple menus and set the correct one depending on the displayed view ? – Andy M Mar 11 '10 at 07:24
  • Hey, andy.. do u know any sample example of stacked-widget.. i read the documentation.. its good.. i need some samples..do u know any samples? – Naruto Mar 11 '10 at 09:41
0

I'd recommend checking out Animation/States example (should be in /qt/examples/animation/states/ subdirectory of your Qt installation). It shows how to combine state machine representing application logic with presentation layer and get cool animation effects for free (of course if you don't need eye candy, you can set widgets properties without any animation).

chalup
  • 8,358
  • 3
  • 33
  • 38