Results 1 to 3 of 3

Thread: QTabWidgets: I can't remove a tab

  1. #1
    Join Date
    Oct 2015
    Location
    Barcelona, Spain
    Posts
    7
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default QTabWidgets: I can't remove a tab

    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:


    Qt Code:
    1. Partes::Partes(QWidget *parent) :
    2. QDialog(parent),
    3. ui(new Ui::Partes)
    4. {
    5. ui->setupUi(this);
    6.  
    7. ui->Pestanas->setCurrentIndex(0);
    8. ui->Pestanas->removeTab(1);
    9. ui->Pestanas->removeTab(2);
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 


    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!

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidgets: I can't remove a tab

    lets say you have 3 tabs, index 0, 1, 2

    Qt Code:
    1. ui->Pestanas->setCurrentIndex(0);
    2. ui->Pestanas->removeTab(1);
    3. ui->Pestanas->removeTab(2);
    To copy to clipboard, switch view to plain text mode 

    You set current tab to first tab. //index 0
    And you removed 2nd tab with //ui->Pestanas->removeTab(1); //index 1
    Now tab indexes will changed, now tab indexes you have are : 0, 1

    And now you are trying to remove 3rd Tab(index 2) which is not there //ui->Pestanas->removeTab(2);


    Try this:
    Qt Code:
    1. ui->Pestanas->removeTab(1);
    2. ui->Pestanas->removeTab(1);
    To copy to clipboard, switch view to plain text mode 
    Thanks :-)

  3. The following user says thank you to prasad_N for this useful post:

    Alberto7 (8th October 2015)

  4. #3
    Join Date
    Oct 2015
    Location
    Barcelona, Spain
    Posts
    7
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QTabWidgets: I can't remove a tab

    Your solution solved my problem!
    Very well explained.

    Thank you very much!

Similar Threads

  1. Size of Widgets in QTabWidgets
    By krassy_gochev in forum Newbie
    Replies: 1
    Last Post: 7th April 2015, 08:00
  2. remove flags?
    By konvex in forum Qt Programming
    Replies: 5
    Last Post: 18th March 2015, 03:26
  3. Remove all translators
    By EdgeLuxe in forum Newbie
    Replies: 1
    Last Post: 27th August 2010, 17:31
  4. Resize the height of QTabWidgets
    By tarod in forum Qt Programming
    Replies: 3
    Last Post: 28th July 2008, 13:48
  5. How to remove background
    By kawazoe in forum Qt Programming
    Replies: 28
    Last Post: 20th May 2007, 02:48

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.