Results 1 to 3 of 3

Thread: event when closing a tab

  1. #1
    Join Date
    Aug 2010
    Posts
    15
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default event when closing a tab

    Hi,

    I'm new to qt, and I have to make a small program to apply filters to photos and it must have a GUI. I have little skills with any GUI framework, so I choosed QT Creator to make the project.

    I'm trying to make the program with tabs to open more than one image. I have in the ui form an empty tabWidget, and I fill it in the code like this:

    QLabel *imageLabel = new QLabel;
    ui->tabWidget->addTab(imageLabel, QString("foo"));

    So my problem here is how can I make a slot/event or whatever it is called so when I clic on x button on the tab it calls the code where I destroy the image, the label, etc.

    The tabs/labels get created dinamically when I open an image, I need a way to destroy the contents of any tab where the user cliced x.

    If I didn't explain it correctly please ask for a better explanation and I'll try, I don't have great English skills.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: event when closing a tab

    QTabWidget::tabCloseRequested() seems to be the obvious signal to connect to a slot. Your tab removal and cleanup code should be in that slot.

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

    fearu (23rd September 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    15
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: event when closing a tab

    Thanks, that is exactly what I needed.

Similar Threads

  1. Timer event & paint event, priority
    By Teuniz in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2010, 13:33
  2. Replies: 10
    Last Post: 15th January 2010, 14:35
  3. how to combine keypress event and mousebuttonpress event?
    By hildebrand in forum Qt Programming
    Replies: 2
    Last Post: 26th May 2009, 23:08
  4. Replies: 0
    Last Post: 23rd October 2008, 12:43
  5. Event - closing/activate window
    By chaimar in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2006, 09:12

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.