Why does QTabBar tabBarDoubleClicked (int) not double-click on the tab bar?

It drives me crazy. The QTabBar documentation says that:

void QTabBar :: tabBarDoubleClicked (int index) [signal]

This signal is emitted when the user double-clicks on the tab with the index. the index refers to the pressed tab or -1 if the tab is not under the cursor.

So, when I double click on the tab bar, is there no need to return -1?

Just to be clear, a bit in the red box is where I try to double-click and where I think it should return -1. It returns the index of the tab when I double-click the tab, so I know that it works correctly. ApplicationWindow

? ? , , ?

, ; , ?

+4
1

.

void MainWindow::on_tabWidget_tabBarDoubleClicked(int index)
{
    qDebug() << index << ui->tabWidget->tabBar()->geometry();
}

- :

0 QRect(0,0 288x29) 
2 QRect(0,0 288x29) 
("G:/x.txt", "G:/xx.txt", "") //something was added
3 QRect(0,0 311x29) //width increased
5 QRect(0,0 311x29) 
4 QRect(0,0 311x29) 

311x29. :

void MainWindow::on_tabWidget_tabBarDoubleClicked(int index)
{
    ui->tabWidget->removeTab(index);
    qDebug() << index << ui->tabWidget->tabBar()->geometry();
}

:

2 QRect(0,0 221x29) 
2 QRect(0,0 154x29) 
1 QRect(0,0 50x21) 
0 QRect(0,0 0x0) 

, , TabBar . TabBar . TabBar

, tabBarDoubleClicked, count(), , .

Edit:

:

void MainWindow::on_tabWidget_tabBarDoubleClicked(int index)
{
    int height = ui->tabWidget->tabBar()->height();
    ui->tabWidget->tabBar()->setGeometry(0,0,ui->tabWidget->geometry().width(), height);
    qDebug() << index << ui->tabWidget->tabBar()->geometry();
}

, setGeometry (, ), , . tabBar , - . :

2 QRect(0,0 311x29) 
1 QRect(0,0 311x29) 
-1 QRect(0,0 311x29) 
-1 QRect(0,0 311x29) 

, -1, , , - ( setGeometry ), , . -1, ( , ). , , .

:

QPushButton *m_addButton = new QPushButton("+", this);
QPushButton *m_addButton1 = new QPushButton("-", this);
m_addButton->resize(15,15);
m_addButton1->resize(15,15);
ui->tabWidget->tabBar()->setTabButton(0, QTabBar::RightSide, m_addButton);
ui->tabWidget->tabBar()->setTabButton(0, QTabBar::LeftSide, m_addButton1);

:

enter image description here

+1

All Articles