1

我想知道当我调用 QWidget-close() 时会发生什么我在编写了一个设置函数后调用了它,这禁用了我的一些插槽以被调用。

之前(产生奇怪的行为):
pGrpCfg->setupGrpConfig();
pGrpCfg->close();
pGrpCfg->show();

after(ok):
pGrpCfg->close();
pGrpCfg->setupGrpConfig();
pGrpCfg->show();

This is my function. The only thing I suspect could have an impact on it is the Signal connections(I would like to add that these connections start in the constructor where I use QSignalMapper):

void grpConfig::setupGrpConfig(){
disconnect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(txGrpComboBoxCurItemChanged(const int)));

disconnect(this, SIGNAL(txGrpComboBoxCurItemChanged(const int)),this,SLOT(updateTxFailOrderLayouts(int)));

myFPS->getData(REQUEST_SYSTEM_CONFIGURATION);
int numTxChains=myFPS->SystemData.NumberOfTransmitterChainsInSystem;
grpList.clear();
grpList.append("Select group");
for(int i=0;i<MAX_GROUPS;i++){
    myFPS->getData(REQUEST_GROUP_INFORMATION,i);
    grpCfgEleList.at(i)->ui.leGrpName->setText(myFPS->GroupData.Group[i].Name);
    grpList.append(myFPS->GroupData.Group[i].Name);
}
for(int i=0;i<numTxChains;i++){

    myFPS->getData(REQUEST_TX_CONFIGURATION,i);
    txNameList.at(i)->setVisible(true);
    txNameList.at(i)->setText(myFPS->TransmitterConfigurationData[i].Name);
    txGrpCBlist.at(i)->setVisible(true);
    txGrpCBlist.at(i)->clear();
    txGrpCBlist.at(i)->addItems(grpList);
    txGrpCBlist.at(i)->setCurrentIndex(myFPS->TransmitterConfigurationData[i].Group+INDEX_OFFSET);

}
for(int i=numTxChains;i<MAX_NUMBER_OF_TRANSMITTERS;i++){
    txNameList.at(i)->setVisible(false);
    txGrpCBlist.at(i)->setVisible(false);
}

for(int i=0;i<MAX_GROUPS;i++){
    updateGrpFailover(i, STAY,-1);
}
//need to wait till setup is complete to activate these signals (populating comboboxes overwrote UDP structs with false data)
connect(signalMapper, SIGNAL(mapped(int)), this, SIGNAL(txGrpComboBoxCurItemChanged(const int)));
connect(this, SIGNAL(txGrpComboBoxCurItemChanged(const int)),this,SLOT(updateTxFailOrderLayouts(int)));

}

4

3 回答 3

2

尝试使用QWidget::hide()而不是close().

于 2010-02-19T02:45:40.323 回答
1

http://doc.trolltech.com/4.6/qwidget.html#close

它准确地告诉你它做了什么。什么类型pGrpCfg?这将告诉您该函数的重新实现版本在做什么。

于 2010-02-19T15:00:02.093 回答
1

答案是:当我调用 QWidget->Close() 时,这会破坏我的信号连接。信号连接是在 setupGrpConfig 中建立的,因此在 setupGrpConfig 使信号连接无效后调用 close 。

于 2011-08-24T19:03:44.293 回答