#๐ PySide6 Frameless Window Snap Problem...
22 messages ยท Page 1 of 1 (latest)
@oblique thicket
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
u have a very huge cursor
...?
I didn't understand what it meant.
image from internet
uh
I don't know either but it would help the next helper if you could share the source code and find out.
wait a s pls
# 1. Window Flags and Attributes
self.setWindowFlags(
QtCore.Qt.WindowType.FramelessWindowHint |
QtCore.Qt.WindowType.Window
)
self.setAttribute(QtCore.Qt.WidgetAttribute.WA_TranslucentBackground, False)
# 2. Windows Native Style Restoration (for Snap/Resize)
if _IS_WIN:
hwnd = int(self.winId())
style = win32gui.GetWindowLong(hwnd, win32con.GWL_STYLE)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE,
style | win32con.WS_CAPTION |
win32con.WS_THICKFRAME |
win32con.WS_MAXIMIZEBOX |
win32con.WS_MINIMIZEBOX)
win32gui.SetWindowPos(
hwnd, None, 0, 0, 0, 0,
win32con.SWP_NOMOVE | win32con.SWP_NOSIZE |
win32con.SWP_NOZORDER | win32con.SWP_FRAMECHANGED
)
# 3. Docking System Configuration
self.setDockOptions(
QtWidgets.QMainWindow.DockOption.AllowNestedDocks |
QtWidgets.QMainWindow.DockOption.AllowTabbedDocks |
QtWidgets.QMainWindow.DockOption.AnimatedDocks
)
self.setTabPosition(QtCore.Qt.DockWidgetArea.AllDockWidgetAreas,
QtWidgets.QTabWidget.TabPosition.North)
# 4. Native Event Handling (Hit Testing for Caption/Borders)
def nativeEvent(self, event_type, message):
if not _IS_WIN:
return super().nativeEvent(event_type, message)
msg = _wt.MSG.from_address(int(message))
if msg.message == win32con.WM_NCHITTEST:
# Handling resize borders (HTTOP, HTBOTTOM, etc.)
# Handling Titlebar (HTCAPTION) vs Client area (HTCLIENT)
if in_caption and not rw_hit and not action_hit:
return True, win32con.HTCAPTION
return True, win32con.HTCLIENT
return False, 0
Hey @oblique thicket!
Add a py after the three backticks.
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
if its super long, use a paste service
So that everyone can easily read your code, you can paste it in this website:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
ok wait..
https://paste.pythondiscord.com/63CA
I have included it in an executable form only.
Minimum code to open a window.
I want it to snap on Windows 10.
how do you mean it doesn't snap?
Does any other app on your pc do the window snap when you drag it to the edges/border?
@oblique thicket it works for me. no code change whatsoever
wait a m pls
Hmm, I have confirmed that it works well in my environment as well.
Previously, it wasn't working properly, so I requested that some content be deleted to post this question. However, it seems to be working well now just by doing that.
For now, I will verify this myself using this file.
Thank you for your help.
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.