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

Handle Qt 6.7 changes to QKeyMapper::possibleKeys, with backwards compatibility #23982

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Aug 11, 2024

Resolves: #23980

Qt 6.7 changes the return type of private QKeyMapper::possibleKeys from QList<int> to QList<QKeyCombination>. A QKeyCombination can easily be transformed into an int by calling its .toCombined() method.

Since MuseScore really wants a QSet<int>, the return value must be transformed regardless. So, to avoid ugly ifdefs, I use auto for the variable that accepts the return from possibleKeys() (which will be either QList<int> or QList<QKeyCombination>), then call a newly-added function convertToSet() which has two overloads: one takes a QList<QKeyCombination>, the other a QList<int>, and both return QSet<int>. The correct one will be called based on what the current version of Qt returns from QKeyMapper::possibleKeys().

This makes the code buildable with Qt 6.7, without affecting its compatibility with earlier versions.

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects, and references the issue it resolves
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine, preferably after each commit individually
  • I created a unit test or vtest to verify the changes I made (if applicable)

Qt 6.7 changes the return type of private `QKeyMapper::possibleKeys`
from `QList<int>` to `QList<QKeyCombination>`. A QKeyCombination
can easily be transformed into an `int` by calling its `.toCombined()`
method.

Avoid ugly ifdefs by changing the type of the variable returned from
`possibleKeys()` to `auto`, and write two overloaded functions that
take either a `QList<QKeyCombination>` or `QList<int>` and output
the `QSet<int>` we really want.

Resolves: musescore#23980
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Aug 12, 2024

(While this does get MuseScore to build successfully with Qt 6.7.2, it doesn't solve the UI issues that remain when running the application. See the discussion in the linked issue for more details.)

@igorkorsukov igorkorsukov merged commit 92fc6a1 into musescore:master Aug 12, 2024
11 checks passed
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.

MuseScore can't be built with Qt 6.7 due to changes in private QKeyMapper
2 participants