Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update for Qt6 #6

wants to merge 3 commits into from

Conversation

jmlich
Copy link

@jmlich jmlich commented Jul 31, 2023

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.

@jmlich jmlich mentioned this pull request Jul 31, 2023
52 tasks
Copy link

@Thaodan Thaodan left a 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.

@jmlich
Copy link
Author

jmlich commented Aug 7, 2023

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.

@Thaodan
Copy link

Thaodan commented Aug 8, 2023

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.

@Thaodan
Copy link

Thaodan commented Aug 8, 2023

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
Copy link
Member

@rainemak rainemak Aug 23, 2023

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.

Copy link
Member

@rainemak rainemak left a 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));
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants