// update text and ensure that extra controls are contained in the // dialog's layout (new layout gets set when setting text)
m_pMessageDialog->setText(toQString(rText));
positionExtraControlsContainer();
}
// update text and ensure that extra controls are contained in the // dialog's layout (new layout gets set when setting text)
m_pMessageDialog->setInformativeText(toQString(rText));
positionExtraControlsContainer();
}
if (QPushButton* pButton = buttonForResponseCode(nResponse)) return std::make_unique<QtInstanceButton>(pButton);
return nullptr;
}
int QtInstanceMessageDialog::run()
{
SolarMutexGuard g;
QtInstance& rQtInstance = GetQtInstance(); if (!rQtInstance.IsMainThread())
{ int nRet = 0;
rQtInstance.RunInMainThread([&] { nRet = run(); }); return nRet;
}
// if a button was clicked, return its response code int nRet = m_pMessageDialog->exec(); if (QAbstractButton* pClickedButton = m_pMessageDialog->clickedButton()) return pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
// if a button was clicked, use its response code, otherwise the passed one int nResponseCode = nResult; if (QAbstractButton* pClickedButton = m_pMessageDialog->clickedButton())
nResponseCode = pClickedButton->property(PROPERTY_VCL_RESPONSE_CODE).toInt();
// make use of implementation detail that QMessageBox uses QGridLayout for its layout // (logic here will need to be adjusted if that ever changes)
QGridLayout* pDialogLayout = qobject_cast<QGridLayout*>(m_pMessageDialog->layout());
assert(pDialogLayout && "QMessageBox has unexpected layout");
// no need to reposition if layout didn't change if (pDialogLayout->indexOf(m_pExtraControlsContainer) >= 0) return;
// find last label constint nItemCount = pDialogLayout->count(); int nLastLabelIndex = -1; for (int i = nItemCount - 1; i >= 0; --i)
{ if (QLayoutItem* pItem = pDialogLayout->itemAt(i))
{ if (qobject_cast<QLabel*>(pItem->widget()))
{
nLastLabelIndex = i; break;
}
}
}
assert(nLastLabelIndex >= 0 && "didn't find label in message box");
// shift everything after the last label down by one row for (int i = nLastLabelIndex + 1; i < nItemCount; ++i)
{ if (QLayoutItem* pItem = pDialogLayout->itemAt(i))
{ int nRow = 0; int nCol = 0; int nRowSpan = 0; int nColSpan = 0;
pDialogLayout->getItemPosition(i, &nRow, &nCol, &nRowSpan, &nColSpan);
pDialogLayout->removeItem(pItem);
pDialogLayout->addItem(pItem, nRow + 1, nCol, nRowSpan, nColSpan);
}
}
// insert an additional layout in the now empty row, underneath the last label int nLabelRow = 0; int nLabelCol = 0; int nLabelRowSpan = 0; int nLabelColSpan = 0;
pDialogLayout->getItemPosition(nLastLabelIndex, &nLabelRow, &nLabelCol, &nLabelRowSpan,
&nLabelColSpan);
pDialogLayout->addWidget(m_pExtraControlsContainer, nLabelRow + 1, nLabelCol);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.