Hello,
I have a QDialog which contains several widgets. The QDialog is used to display the various properties of a member object of type MyObject.
The QDialog is modeless and can be udated on the fly with a new object using:
void MyDialog::SetMyObject(MyObject* i_pObject)
{
if (m_pObject != i_pObject)
{
m_pObject = i_pObject;
ModelToUI();
}
}
void MyDialog::SetMyObject(MyObject* i_pObject)
{
if (m_pObject != i_pObject)
{
m_pObject = i_pObject;
ModelToUI();
}
}
To copy to clipboard, switch view to plain text mode
The ModelToUI() function will update every widgets according to the content of m_pObject:
void MyDialog::ModelToUI()
{
if (m_pObject!= NULL)
{
m_pObjectNameEdit->setText(m_pObject->GetName());
[....]
}
}
void MyDialog::ModelToUI()
{
if (m_pObject!= NULL)
{
m_pObjectNameEdit->setText(m_pObject->GetName());
[....]
}
}
To copy to clipboard, switch view to plain text mode
This is where I am running into a problem, every time the ModelToUI() function is called and setText() is called, it will also launch textChanged signal which I have connected. Then, it will do a bunch of processing for every widgets.
This is what I am trying to avoid. I am aware of the :
m_pObjectNameEdit->blockSignals(true);
m_pObjectNameEdit->setText(m_pObject->GetName());
m_pObjectNameEdit->blockSignals(false);
m_pObjectNameEdit->blockSignals(true);
m_pObjectNameEdit->setText(m_pObject->GetName());
m_pObjectNameEdit->blockSignals(false);
To copy to clipboard, switch view to plain text mode
But I was wondering if there was a way to block ALL signals for every children widgets contained in a dialog without having to use blockSignals for every single on of them. Something I could use in SetMyObject() function just before and after the ModelToUI() call.
I am also aware that in this particular case connecting textEdited instead of textChanged would solve the problem, but I also have a bunch of QRadioButton and QSpinBox widgets.
Any help would be appreciated, thank you!
Bookmarks