QmlProjectManager: Add widgetApp qml project property

Widget was the default apptype in Qt5, but in Qt6 the default was
changed to gui, so projects with qml modules that depend on widgets can
no longer be launched. Notable example of this is QtCharts.

Added "widgetApp" qml project property to allow users to specify if
they want widget or gui based application.

Task-number: QDS-5686
Change-Id: If0787421c79d4ba24a0f8513c8538126bcf29b4e
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Miikka Heikkinen
2021-12-07 15:04:04 +02:00
parent 8c139603a1
commit c17f633a7e
5 changed files with 21 additions and 0 deletions

View File

@@ -123,6 +123,10 @@ QmlProjectItem *QmlProjectFileFormat::parseProjectFile(const Utils::FilePath &fi
if (qt6ProjectProperty.isValid() && qt6ProjectProperty.value.toBool())
projectItem->setQt6Project(qt6ProjectProperty.value.toBool());
const auto widgetAppProperty = rootNode->property("widgetApp");
if (widgetAppProperty.isValid())
projectItem->setWidgetApp(widgetAppProperty.value.toBool());
if (debug)
qDebug() << "importPath:" << importPathsProperty.value << "mainFile:" << mainFileProperty.value;

View File

@@ -78,6 +78,9 @@ public:
QString mainFile() const { return m_mainFile; }
void setMainFile(const QString &mainFilePath) { m_mainFile = mainFilePath; }
bool widgetApp() const { return m_widgetApp; }
void setWidgetApp(bool widgetApp) { m_widgetApp = widgetApp; }
void appendContent(QmlProjectContentItem *item) { m_content.append(item); }
Utils::EnvironmentItems environment() const;
@@ -99,6 +102,7 @@ protected:
bool m_forceFreeType = false;
bool m_qtForMCUs = false;
bool m_qt6Project = false;
bool m_widgetApp = false;
};
} // namespace QmlProjectManager

View File

@@ -585,6 +585,13 @@ bool QmlBuildSystem::forceFreeType() const
return false;
}
bool QmlBuildSystem::widgetApp() const
{
if (m_projectItem)
return m_projectItem.data()->widgetApp();
return false;
}
bool QmlBuildSystem::addFiles(Node *context, const FilePaths &filePaths, FilePaths *)
{
if (!dynamic_cast<QmlProjectNode *>(context))

View File

@@ -93,6 +93,7 @@ public:
QString primaryLanguage() const;
void setPrimaryLanguage(QString language);
bool forceFreeType() const;
bool widgetApp() const;
bool addFiles(const QStringList &filePaths);

View File

@@ -227,6 +227,11 @@ QString QmlProjectRunConfiguration::commandLineArguments() const
ProcessArgs::addArg(&args, "windows:fontengine=freetype", osType);
}
if (bs->qt6Project() && bs->widgetApp()) {
ProcessArgs::addArg(&args, "--apptype", osType);
ProcessArgs::addArg(&args, "widget", osType);
}
const QString main = bs->targetFile(FilePath::fromString(mainScript())).toString();
if (!main.isEmpty())
ProcessArgs::addArg(&args, main, osType);