// Name of QObject property set on QWizardPage objects for the page // index as used in the weld::Assistant API. // This is different from the page id as used in the QWizard API constchar* const PROPERTY_PAGE_INDEX = "page-index";
GetQtInstance().RunInMainThread([&] { #if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0) const QList<int> aPageIds = m_pWizard->pageIds(); for (int nId : aPageIds)
{
QWizardPage* pPage = m_pWizard->page(nId);
assert(pPage); if (pageIndex(*pPage) == nPage)
{
m_pWizard->setCurrentId(nId); return;
}
} #else // QWizard::setCurrentId only available from 6.4 on // start with first page and advance until the expected one is the current one
m_pWizard->restart(); int nCurrentId = m_pWizard->currentId(); while (nCurrentId != -1 && pageIndex(*m_pWizard->page(nCurrentId)) != nPage)
m_pWizard->next(); #endif
});
}
// QWizard page IDs are different from weld::Assistant page indices // use a vector where items will be sorted by page index for help
QList<QWizardPage*> aPages; int nOldIndex = -1; const QList<int> aPageIds = m_pWizard->pageIds(); for (int nPageId : aPageIds)
{
QWizardPage* pPage = m_pWizard->page(nPageId);
assert(pPage);
aPages.push_back(pPage); if (pPage->objectName() == sIdent)
nOldIndex = pageIndex(*pPage);
}
assert(nOldIndex >= 0 && "no page with the given identifier");
// sort vector by page index
std::sort(aPages.begin(), aPages.end(), [](QWizardPage* pFirst, QWizardPage* pSecond) { return pageIndex(*pFirst) < pageIndex(*pSecond);
}); // remove and reinsert the page at new position
QWizardPage* pPage = aPages.takeAt(nOldIndex);
aPages.insert(nIndex, pPage);
// update index property for all pages for (qsizetype i = 0; i < aPages.size(); ++i)
setPageIndex(*aPages.at(i), i);
});
}
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.