当我调用 QWidget->close() 时会发生什么

发布于 2024-08-21 17:48:07 字数 2135 浏览 8 评论 0原文

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

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

之后(确定):
pGrpCfg->close();
pGrpCfg->setupGrpConfig();
pGrpCfg->show();

这是我的功能。我怀疑唯一可能对其产生影响的是信号连接(我想补充一点,这些连接在我使用 QSignalMapper 的构造函数中启动):

无效 grpConfig::setupGrpConfig(){
断开(signalMapper,信号(映射(int)),这个,信号(txGrpComboBoxCurItemChanged(const int)));

断开连接(此,信号(txGrpComboBoxCurItemChanged(const int)),此,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)));

}

I would like to know what happens when I call QWidget-close() I called it after a setup function I coded and this disabled some of my slots to get called.

before(creates odd behavior):

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)));

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

枫以 2024-08-28 17:48:07

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

Try using QWidget::hide() instead of close().

樱花坊 2024-08-28 17:48:07

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

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

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

It tells you exactly what it does. What type is pGrpCfg?
That will tell you what the reimplemented version of the function is doing.

回忆凄美了谁 2024-08-28 17:48:07

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

The answer is: when I called QWidget->Close(), this destroys my signal connection. The signal connections are made in setupGrpConfig so to call close after setupGrpConfig voided the signal connections.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文