Signals not found for QTabWidget

My QTabWidget implementation does not detect signals tabCloseRequested()

and currentChanged()

.

TileSheetManager::TileSheetManager(QWidget *parent)
: QTabWidget(parent)
{
    int w = WIDTH;
    int h = HEIGHT;

    this->setMinimumSize(w, h);
    this->setMaximumSize(w, h);

    setTabsClosable(true);
    setTabShape(QTabWidget::Rounded);

    connect(this, SIGNAL(tabCloseRequested(int index)), this, SLOT(closeTileWidget(int index)));
    connect(this, SIGNAL(currentChanged(int index)), this, SLOT(tabChanged(int index)));
}

      

qDebug()

didn't work for me, so I use QMessageBox

for that.

void TileSheetManager::closeTileWidget(int index)
{
   QMessageBox msgBox;
   msgBox.setText("Tab " + QString::number(index) + " removed!");
   msgBox.exec();

   TileWidget *t = (TileWidget *) widget(index) ;
   t->deleteLater();
   removeTab(index);
}

void TileSheetManager::tabChanged(int index)
{   
    QMessageBox msgBox;
    msgBox.setText("Tab was Changed!");
    msgBox.exec();

    TileWidget *t;

    for(int i = 0; i < count(); i++)
    {
        t = (TileWidget *) widget(i) ;
        t->resetSetBrush();
    }
} 

      

The tabs are not closing, the selected brushes are not reset and I am not getting any messages, so I conclude that no signals are being picked up. Which is weird because I used similar code for a previous project, in which case it worked.

+3


source to share


1 answer


Don't use variable names in connect

:

Please note that signal and slot parameters must not contain any variable names, only the type.



The connection must be

connect(this, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTileWidget(int)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));

      

+7


source







All Articles