3
我的QTabWidget实现未检测到它的tabCloseRequested()
和currentChanged()
信号。信号未被检测到QTabWidget
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()
不是为我工作,所以我使用这个QMessageBox
。
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();
}
}
标签没有得到关闭,选择刷不重,我也得到任何消息,所以我总结的信号不被拾起。这很奇怪,因为我对以前的项目使用过类似的代码,在这种情况下它工作正常。
谢谢!有效。不过,我的另一个信号插槽连接,插槽参数中的变量名正在工作。你有什么想法,为什么?再次感谢。 – Rikonator 2012-04-02 14:18:16
我有同样的问题,我没有在连接变量名称,仍然没有拿起信号......任何想法? – 2012-08-14 11:57:31