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. [Solved] QTabWidgets: I can't remove one tab
QtWS25 Last Chance

[Solved] QTabWidgets: I can't remove one tab

Scheduled Pinned Locked Moved General and Desktop
qtabwidgettabsremove
6 Posts 2 Posters 2.6k 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.
  • A Offline
    A Offline
    Alberto
    wrote on 8 Oct 2015, 01:35 last edited by Alberto 10 Aug 2015, 17:59
    #1

    Hello,
    Sorry for my English. I'm new to Qt, in my project the user can move from one tab to the next one. ( Slot of the button: ui->Pestanas->insertTab(1, ui->Pestana_Orden_Trabajo, "Orden de Trabajo");
    ui->Pestanas->setCurrentIndex(1); )

    It works, but I would like to just show the first tab when the window appears for the first time.
    I've tried this:

    Partes::Partes(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::Partes)
    {
        ui->setupUi(this);
    
        ui->Pestanas->setCurrentIndex(0);
        ui->Pestanas->removeTab(1);
        ui->Pestanas->removeTab(2);
    
    }
    

    It makes disappear the second tab that comes with the QTabWidget deffault form when you first include it in the ui. But the the tab that I added for designing the widgets I want it to bring inside doesn't disappear.

    Does anyone know any way to do it?

    Thanks for replying!

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jakob
      wrote on 8 Oct 2015, 05:54 last edited by
      #2

      @Alberto You can remove tabs from the designer. Then there is no need for the remoteTab call, and your first tab will always be the active tab

      A 1 Reply Last reply 8 Oct 2015, 13:38
      0
      • J Jakob
        8 Oct 2015, 05:54

        @Alberto You can remove tabs from the designer. Then there is no need for the remoteTab call, and your first tab will always be the active tab

        A Offline
        A Offline
        Alberto
        wrote on 8 Oct 2015, 13:38 last edited by
        #3

        @Jakob Thanks @Jakob . But how can I design the widgets I want to appear in the tab if I don't create the tab in the designer?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Alberto
          wrote on 8 Oct 2015, 15:42 last edited by
          #4

          Solved.
          The problem was that when it does the first remove the indexes change, so when I remove index 1 indexes go from being 0,1,2 to be 0,1. The second remove tries to remove index 2 that stopped existing when I did the first remove.
          So the solution is:

          Partes::Partes(QWidget *parent) :
              QDialog(parent),
              ui(new Ui::Partes)
          {
              ui->setupUi(this);
          
              ui->Pestanas->setCurrentIndex(0);
              ui->Pestanas->removeTab(1);
              ui->Pestanas->removeTab(1);
          
          }
          

          Or:

          Partes::Partes(QWidget *parent) :
              QDialog(parent),
              ui(new Ui::Partes)
          {
              ui->setupUi(this);
          
              ui->Pestanas->setCurrentIndex(0);
              ui->Pestanas->removeTab(2);
              ui->Pestanas->removeTab(1);
          
          }
          

          How can I mark this post as solved?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jakob
            wrote on 8 Oct 2015, 17:55 last edited by
            #5

            Marking a post as solved is done by putting the string [Solved] as the first string in your title

            1 Reply Last reply
            1
            • J Offline
              J Offline
              Jakob
              wrote on 8 Oct 2015, 17:59 last edited by
              #6

              To be precise: click the gear, choose 'Edit' en put the string [Solved] in front of the title of your post

              1 Reply Last reply
              0

              1/6

              8 Oct 2015, 01:35

              • Login

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