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. Implement a code before closing the Tab/Widget
Forum Updated to NodeBB v4.3 + New Features

Implement a code before closing the Tab/Widget

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 756 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.
  • P Offline
    P Offline
    Prmego
    wrote on 24 Apr 2017, 01:13 last edited by Prmego
    #1

    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?

    J 1 Reply Last reply 24 Apr 2017, 04:39
    0
    • P Prmego
      24 Apr 2017, 01:13

      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?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 24 Apr 2017, 04:39 last edited by
      #2

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

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Prmego
        wrote on 24 Apr 2017, 09:52 last edited by Prmego
        #3

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

        1 Reply Last reply
        0

        1/3

        24 Apr 2017, 01:13

        • Login

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