Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

qt: Use better devicePixelRatio event to refresh scaling#30345

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
QuLogic merged 1 commit intomatplotlib:mainfromQuLogic:qt-better-hidpi
Jul 24, 2025

Conversation

@QuLogic
Copy link
Member

PR summary

With Qt 6.6, there is an event on the window that signals when the devicePixelRatio has changed. This is better than before when we had to rely on the underlyingQScreen, which doesn't correctly refresh when a fractional scale is used.

Fixes#30218

PR checklist

@QuLogicQuLogic added this to thev3.10.4 milestoneJul 23, 2025
@tacaswell
Copy link
Member

Confirmed that this Fixes#30218

Comment on lines 160 to 162
# Emitting this event is simply to trigger the DPI change handler
# in Matplotlib in the same manner that it would occur normally.
qt_canvas.eventFilter(
Copy link
Member

Choose a reason for hiding this comment

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

Is calling eventFilter() the standard way to emit a self-created event? This feels a bit hacky, which may be ok. But I'd rathe comment like this

Suggested change
# Emitting this event is simply to trigger the DPI change handler
# in Matplotlib in the same manner that it would occur normally.
qt_canvas.eventFilter(
# Create an event to explicitly trigger the DPI change handler.
# We push the event into Qt's event handling system by injecting it into
# the eventFilter
qt_canvas.eventFilter(

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I just copied the old form, but we can push an event normally.

@QuLogicQuLogicforce-pushed theqt-better-hidpi branch 2 times, most recently from97c3be7 toa23bb28CompareJuly 23, 2025 21:06
With Qt 6.6, there is an event on the window that signals when thedevicePixelRatio has changed. This is better than before when we had torely on the underlying `QScreen`, which doesn't correctly refresh when afractional scale is used.Fixesmatplotlib#30218
@QuLogic
Copy link
MemberAuthor

Note, I think we don't need theqt_core fixture any more, but since this is going to 3.10.4, I was going to leave removing that to a separate PR for 3.11.

Comment on lines +275 to +279
ifcurrent_version>= (6,6):
window.installEventFilter(self)
else:
window.screenChanged.connect(self._update_screen)
self._update_screen(window.screen())
Copy link
Member

Choose a reason for hiding this comment

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

I suspect that both cases are a bit sloppy in that they connect/install on every showEvent. We typically have one, but there may be cases where the window lives longer and is hidden/shown multiple times. At least forconnect() multiple calls result in multiple connections, i.e. firing multiple times.

Copy link
Member

Choose a reason for hiding this comment

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

atleast for the event filter version

If filterObj has already been installed for this object, this function moves it so it acts as if it was installed last.

so it is OK to install it multiple times.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I'm not sure if I could find a better event just yet, but I'll try to take a look again later.

Copy link
Member

@tacaswelltacaswell left a comment

Choose a reason for hiding this comment

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

@QuLogic can self merge if he would like to deal with note about possible multiple connections in a follow on PR.

@QuLogicQuLogic merged commit93ed6de intomatplotlib:mainJul 24, 2025
40 checks passed
@QuLogicQuLogic deleted the qt-better-hidpi branchJuly 24, 2025 18:45
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJul 24, 2025
@cbrnr
Copy link
Contributor

Thank you 🔥! So happy to get nice looking Matplotlib plots now! I haven't tested it though, when will this fix be available in a release?

@tacaswell
Copy link
Member

We are going to do a 3.10.4 this week (mostly to the fix for py3.14 released) so this made it in under the wire.

cbrnr reacted with heart emoji

ksunden added a commit that referenced this pull requestJul 25, 2025
…345-on-v3.10.xBackport PR#30345 on branch v3.10.x (qt: Use better devicePixelRatio event to refresh scaling)
@cgohlke
Copy link
Contributor

This doesn't work for me on Windows 11, PyQt6 6.9.1, 4K display. The figures are very pixelated, especially noticeable on text. Reverting these changes, or downgrading to matplotlib 3.10.3, or using another backend resolves the issue. For example,text3d.py:

matplotlib 3.10.5
image

matplotlib 3.10.3
image

@cbrnr
Copy link
Contributor

I will test this tomorrow on Wayland...

@ksundenksunden mentioned this pull requestAug 7, 2025
5 tasks
@anntzeranntzer mentioned this pull requestAug 11, 2025
2 tasks
ksunden pushed a commit to ksunden/matplotlib that referenced this pull requestAug 21, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@tacaswelltacaswelltacaswell approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

v3.10.5

Development

Successfully merging this pull request may close these issues.

[Bug]: Rendering on Wayland with fractional scaling looks bad

5 participants

@QuLogic@tacaswell@cbrnr@cgohlke@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp