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

Backwards-compatible Qt6 support #50

Merged
merged 6 commits into from
Mar 3, 2022
Merged

Conversation

prototypicalpro
Copy link
Contributor

This PR aims to finish the work started by @faaxm in #29: it contains the same changes plus reworking of the CMake files to allow for Qt5 and Qt6 support (I didn't attempt to add support for optional libraries). The reworks are as follows:

  • Added a SPIX_QT_MAJOR cache variable which controls which major Qt version Spix builds against (right now it defaults to Qt6). Updated all CMake files to use this variable.
  • Bumped minimum CMake to 3.18 to support cmake_language. This change could be reverted if needed, but the alternative is a bit hacky.
  • Updated CI to test Qt5.12, Qt5.15 and Qt6.2.
  • Added some other stuff to the README

@faaxm let me know if you would like me to make any changes (or feel free to push changes yourself).

* changed cmake files to use qt6 instead of qt5
* changed travis ci to use qt6 and only macos (for now)
@prototypicalpro prototypicalpro changed the title Qt6 support Backwards-compatible Qt6 support Feb 21, 2022
Copy link
Owner

@faaxm faaxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that's a pretty nice PR :-) Thank you @prototypicalpro for finishing the Qt6 support! And bonus points for improving the README, that's really welcome.

There is one point where the mouse up event actually has to be constructed differently in the two versions, but otherwise looks good.

Comment on lines 117 to 121
m_pressedMouseButtons ^= button;
Qt::MouseButton eventCausingButton = getQtMouseButtonValue(button);
Qt::MouseButtons activeButtons = getQtMouseButtonValue(m_pressedMouseButtons);
m_pressedMouseButtons ^= button;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this change breaks compatibility with Qt5. You can see this when you run the example apps under Qt5. The basic example will only report Button 1 presses, the RepeaterLoader one will not work at all. Sorry I forgot to mention this earlier...

When first looking into Qt6+5 support, I didn't find any proper documentation on why Qt5 seems to expect activeButtons to be the state after the mouseUp, while Qt6 expects activeButtons to be the state before the event. I only figured this out by experiment :-/

I think we can use the QT_VERSION macro here. A bit ugly, but I guess that's how it has to be :(
https://doc.qt.io/qt-5/qtglobal.html#QT_VERSION_CHECK

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good! I updated the code to use QT_VERSION_CHECK and added the RepeaterLoader and GTest examples to CI so it'll catch bugs like this in the future.

.github/workflows/build.yml Outdated Show resolved Hide resolved
@prototypicalpro prototypicalpro force-pushed the qt6-support branch 7 times, most recently from 36878df to 36d73e2 Compare February 28, 2022 20:09

add_executable(SpixRepeaterLoaderExample "main.cpp" "qml.qrc")
add_executable(SpixRepeaterLoaderExampleGTest "main_gtest.cpp" "qml.qrc")
Copy link
Contributor Author

@prototypicalpro prototypicalpro Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this could be it's own example if needed, but I figured just adding another target was the easiest way w/o copying every resource file.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

Copy link
Owner

@faaxm faaxm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks a lot!


add_executable(SpixRepeaterLoaderExample "main.cpp" "qml.qrc")
add_executable(SpixRepeaterLoaderExampleGTest "main_gtest.cpp" "qml.qrc")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

This was referenced Mar 3, 2022
@faaxm faaxm merged commit 3b758e8 into faaxm:master Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants