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 temporarily replace the widget of an existing tab?
Forum Updated to NodeBB v4.3 + New Features

How to temporarily replace the widget of an existing tab?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 203 Views
  • 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.
  • S Offline
    S Offline
    sarimcharania
    wrote on last edited by
    #1

    Re: Qtabwidget change widget of existing tab

    For example I have multiple widgets of the same class that I want to switch between, the first widget has been added to the tab using the addTab function, Now I want a new object to appear in this tab and hide the current widget, the question I have linked to says the only way to change the widget of an existing tab is to remove the tab and insert a new one. Although the problem with this is that I dont want to lose the saved contents of the previous widget and want the possibility for making it reappear when I need it again.

    What can be a solution to that? Thanks in advance

    JonBJ JoeCFDJ 2 Replies Last reply
    0
    • S sarimcharania

      Re: Qtabwidget change widget of existing tab

      For example I have multiple widgets of the same class that I want to switch between, the first widget has been added to the tab using the addTab function, Now I want a new object to appear in this tab and hide the current widget, the question I have linked to says the only way to change the widget of an existing tab is to remove the tab and insert a new one. Although the problem with this is that I dont want to lose the saved contents of the previous widget and want the possibility for making it reappear when I need it again.

      What can be a solution to that? Thanks in advance

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @sarimcharania
      Before you go any further, are you wedded to a QTabWidget anyway? You want to switch between multiple widgets, showing one at any time. And you want to be able to keep each widget's state when you switch away from it so you can return to it or still get its values. A QStackedWidget seems to fit that bill? Then there isn't an issue about replacing tabs.

      S 1 Reply Last reply
      4
      • S sarimcharania

        Re: Qtabwidget change widget of existing tab

        For example I have multiple widgets of the same class that I want to switch between, the first widget has been added to the tab using the addTab function, Now I want a new object to appear in this tab and hide the current widget, the question I have linked to says the only way to change the widget of an existing tab is to remove the tab and insert a new one. Although the problem with this is that I dont want to lose the saved contents of the previous widget and want the possibility for making it reappear when I need it again.

        What can be a solution to that? Thanks in advance

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @sarimcharania Same class, right? If yes, create a model and change the contents, but not the widgets.

        1 Reply Last reply
        1
        • JonBJ JonB

          @sarimcharania
          Before you go any further, are you wedded to a QTabWidget anyway? You want to switch between multiple widgets, showing one at any time. And you want to be able to keep each widget's state when you switch away from it so you can return to it or still get its values. A QStackedWidget seems to fit that bill? Then there isn't an issue about replacing tabs.

          S Offline
          S Offline
          sarimcharania
          wrote on last edited by
          #4

          @JonB much appreciated. That is exactly the solution I was looking for.

          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