Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Problem in clearing the tab from tabwidget

    General and Desktop
    3
    3
    996
    Loading More Posts
    • 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
      Indrajeet last edited by

      Hi

      I have added a tab widget in my ui file.
      In one of the tab of this tab widget I am dynamically creating the another tabwidget.
      This creation of dynamic tabwidget I am doing on some button click SLOT.
      So I want to remove or clear the tab each time the button is clicked and then create the tabwidget inside tab dynamically.

      How to do this?

      1 Reply Last reply Reply Quote 0
      • B
        b1gsnak3 last edited by

        Do you mean you have double tab widgets (tab widget inside a tab of a tabwidget)? Or do you mean you are removing one tab from your tabwidget and adding another one?

        1 Reply Last reply Reply Quote 0
        • Jeroentjehome
          Jeroentjehome last edited by

          Hmm, Maybe a strange way of doing things, but why a tab widget in a tab widget. Isn't it better to have a listwidget in the tab and add/remove items there, use the selected slots there to select the stackedwidget item to display next to it. That is probably much more common and user friendly. But to get to the question asked. the tabWidget is easily created with
          @QTabWidget dynTab = new QTabWidget(ui->tabWidget);@
          The dynamic tab needs to be hold by a layout or a frame to be added to the main tabwidget IYAM.
          The insert new tabs to it and all done. Remember that remove tab doesn't really remove the widget it holds!! You have to remove the allocated memory yourself (or wait for the program to be closed, it will be done then) or keep it in memory and add it again to the tabwidget if needed.
          (not tested this idea, but hopes this gives some help)
          Greetz

          Greetz, Jeroen

          1 Reply Last reply Reply Quote 0
          • First post
            Last post