0

I have created several menu items in the Qt creator, for example : Item X Item Y Item Z
after creating the menu items, I created different classes with different ui for each item - for example Item_x.cpp Item_x.h and Item_X.ui and added my content to each one

now I want to be able to link Item X to Item_x.ui so when the user clicks on the Item X that specific content is loaded . The other issue is that I already have a mainwindow.ui and the menu is set up there.
I am not sure how to connect each Item to its ui, so when the user clicks Item X the Item_x.ui content appears

Andy M
  • 167
  • 1
  • 2
  • 7

1 Answers1

0

There are few possible solutions. May be in your situation QStackedWidget is the best one. You can put instance of QStackedWidget in your mainwindow. After it you can append in this QStackedWidget all your three screens (just call addWidget method for each window on the initialization step of your application). After it, each time user click on item on main menu, your application will change current visible screen in QStackedWidget (you have to implement code for it, of course).

Ilya
  • 4,583
  • 4
  • 26
  • 51
  • thank you for the comment, I am not sure how to use `connect(ui.actionObject, SIGNAL(triggered()), this, SLOT(clickMenuButton()));` to connect the item to a widget – Andy M Nov 15 '13 at 05:28
  • In the implementation of clickMenuButton() you have to add code for switching of current active screen of your container of three screens (QStackedWidget). – Ilya Nov 15 '13 at 05:46
  • sorry if I am jumping around, but what if we want to open a new ui in terms of pop up screen to display the content? for example : when you click `help` in the notepad, a small popup screen will open with content – Andy M Nov 15 '13 at 06:04
  • Open new window for each .ui is much easier than my proposition. Just show() proper screen in implementation of clickMenuButton(). – Ilya Nov 15 '13 at 06:21