Implement a code before closing the Tab/Widget



  • I have the following program:

    ScreenShot

    Each tab has hidden data which contain the full path of the file (I have used setProperty function to assign the hidden data to the tab/widget).
    Now, when you click on the close button, I want to get the hidden data of this window before implements the closing command.

    Note that I have used tabCloseRequested slot but it returns wrong data.

    QObject::connect(this->tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(on_subWindow_tabCloseRequested(int)));
    
    void PSubWindow::on_subWindow_tabCloseRequested(int index) {
        qDebug()<< this->tabs->tabText(index); // return empty string.
    }
    

    What is the signal which responsible for closes the tab/widget, but it must give me a possibility to implement a code before closing the tab/widget?


  • Moderators

    @Prmego Should work. Did you check the value of index?



  • @jsulm: Yes, I did and the index is correct, but the tabText(index) returns an empty string.


Log in to reply