我没有QT6的WebApps经验。在常规桌面C ++应用中,我经常使用这样的代码。
void switchToView(QWidget* pPage) {
qDebug() << "trying to switch to another view";
if (!pPage) {
qDebug() << "the new view is NULL, aborting...";
return;
}
if (pPage->parentWidget() != ui->stackedWidget) {
qDebug() << "the new view is not a page of the stacked widget, aborting...";
return;
}
qDebug() << "switching to page" << pPage->objectName();
ui->stackedWidget->setCurrentWidget(pPage);
}
真正重要的事情发生在最后一行中,只需使用集合当前小部件函数,但请确保提供一个实际上是堆叠式小部件的孩子的小部件。
最终在QT6中对Web应用程序的工作或多或少相同。