antonypro / QGoodWindow

QGoodWindow - border less window for Qt 5 and Qt 6
MIT License
506 stars 87 forks source link

Menubar in titlebar is not visible in second monitor #51

Closed Pikachuxxxx closed 7 months ago

Pikachuxxxx commented 8 months ago

Hi, wow this is a amazing project thanks for it! So while I was playing around with the examples, GoodShowCase renders the main menu with an offset when moved to second monitor.

Could be a QT bug not sure, will investigate more on my side as well.

Using QGoodWindow : 2.4.2 QT Version : 5.14.2 Windows 11

Pikachuxxxx commented 8 months ago
int mouseScreen = qApp->desktop()->screenNumber(QCursor::pos());

QScreen* screen = qApp->screens()[mouseScreen];//windowHandle()->screen();

widget->windowHandle()->setScreen(screen);

int x = qFloor(screen->geometry().x() / m_pixel_ratio);
int y = qFloor(screen->geometry().y() / m_pixel_ratio);

x += widget->x() - screen->geometry().topLeft().x();
y += widget->y() - screen->geometry().topLeft().y();

In qgoodwindow.cpp line 2006 onwards where the QMenu class is Handled, we will have to subtract the top left for it to work properly on multiple monitors, nor sure if this the right way to get the screen but seems to do the fix for now.

antonypro commented 7 months ago

Hi, @Pikachuxxxx!

This problem occurs on a secondary monitor without high DPI on Qt 5.14 and Qt 5.15.

To solve this problem, before reposition the menu, the library asks if the window is on a monitor with high DPI or not.

You can test it in QGoodWindow-2.4.3-beta3: https://github.com/antonypro/QGoodWindow/tree/test/QGoodWindow-2.4.3-beta3

Thanks!

antonypro commented 7 months ago

Hi, @Pikachuxxxx!

I'm going to close this issue because the solution is present in version 2.4.3. If you believe that are problems remaining, please ask to reopen this issue or open a new issue.

Thanks!