SeriousAlexej / TabToolbar

A small library for creating tabbed toolbars
Other
284 stars 108 forks source link

Dual Screen Crash #12

Open haknkayaa opened 2 years ago

haknkayaa commented 2 years ago

Hi, I have a TabToolbar that works fine when using a single screen. But when I open the project with a dual screen attached to my computer, it crashes.

I found that the crash happens in this function when opened with debug mode. (StyleTools.cpp)

float GetScaleFactor(const QWidget& widget)
{
#if (QT_VERSION <= QT_VERSION_CHECK(5, 10, 0))
    auto scrNumber = QApplication::desktop()->screenNumber(widget.mapToGlobal(QPoint(0,0)));
    auto screens = QGuiApplication::screens();
    QScreen* scr = screens.at(scrNumber);
#else
    QScreen* scr = QGuiApplication::screenAt(widget.mapToGlobal(QPoint(0,0)));
#endif
    const float defaultDpi = 96.0f;
    return scr->logicalDotsPerInchY() / defaultDpi;
}

By the way, my screens have different resolutions.

1st screen: 1920x1080 (16.9) 2nd screen: 2560x1440 (16:9)

Anyone have any ideas about the problem? Thanks.