New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update for Qt6 #6
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that these changes are all for Qt 6? In most cases they apply to later Qt5 versions too.
I'm not sure about the QML changes.
|
Yes, big part can be applied also with older Qt. Testing down to Qt 5.6 is quite difficult for me as I need to install another virtual machine. Actually, I would like to do more tests with Qt6. |
|
You can check the Qt docs to which those changes apply to. Most changes that are breaking in Qt 6 where deprecated in later Qt 5 versions. |
|
I can test the changes on Qt 5.6. |
| @@ -18,7 +18,7 @@ | |||
| */ | |||
|
|
|||
| import QtQuick 2.0 | |||
| import QtQuick.XmlListModel 2.0 | |||
| import QtQml.XmlListModel | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work with Qt5.x as version number is mandatory with it. One simple approach could go as follows
- Rename / copy qml/MenuFingerterm.qml to qml/MenuFingerterm5.qml and qml/MenuFingerterm6.qml
- Have Qt6 changes in qml/MenuFingerterm6.qml and Qt5 in qml/MenuFingerterm5.qml
- Expose Qt major version to the root context or have it as a singleton
- On qml/Main.qml use Loader to load correct menu
Something like this to Main.qml to replace MenuFingerterm
Loader {
id: menu
readonly property showing: item && item.showing
anchors.fill: parent
source: QtMajorVersion === 5 ? Qt.resolvedUrl("MenuFingerterm5.qml") : Qt.resolvedUrl("MenuFingerterm6.qml")
}
Point is that neither of these menu component won't get compiled when Main.qml is compiled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qml/MenuFingerterm.qml should be separated per major Qt version. That'd be relatively simple way to cope major version changes.
| iFont.setStyleHint(QFont::Monospace, QFont::StyleStrategy(QFont::PreferDefault | QFont::ForceIntegerMetrics)); | ||
| #else | ||
| iFont.setStyleHint(QFont::Monospace, QFont::StyleStrategy(QFont::PreferDefault)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer default would be the default so does this do anything? For second thing is even the earlier ForceIntegerMetrics doing anything since there is QFontMetrics used for sizes as suggested by the deprecation notice?
I am not sure if there is reasonable way to make it compatible with both Qt5 and Qt6.
Let me know if you want to include some of my changed, I will prepare separate pull request.