Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to change widget in QMainWindow
Forum Updated to NodeBB v4.3 + New Features

How to change widget in QMainWindow

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 227 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Infinity
    wrote on last edited by
    #1

    I have a QMainWindow with a tree view on the left hand side. On the right had side there should be different widgets depending on the selection of the tree view. When the user selects a row from the tree view, the widget on the right hand side should change. How can I achieve this?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You can use a QStackedWidget and associate the index of each widget in it to the corresponding item in your QTreeView. So when you click on an item of your tree, you trigger the selection of the corresponding index in your QStackedWidget.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      I 1 Reply Last reply
      3
      • SGaistS SGaist

        Hi,

        You can use a QStackedWidget and associate the index of each widget in it to the corresponding item in your QTreeView. So when you click on an item of your tree, you trigger the selection of the corresponding index in your QStackedWidget.

        I Offline
        I Offline
        Infinity
        wrote on last edited by
        #3

        @SGaist Perfect. That is what I was looking for. Thank you very much.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved