Important: Please read the Qt Code of Conduct -

scale widget-based app

  • I have a widget-based desktop application, on which I need to make all items larger, because user will be somewhat further from computer screen. Is there a way to do this?

    I searched the Internet and found that widgets scale themselves according to QScreen::devicePixelRatio(). However, I couldn't find out how to override its return value.

    I'm using Qt 5.5.1.

  • Lifetime Qt Champion


    What kind of application is it ?

  • It's application for recording passing times of participants in a sports tournament.

  • This post is deleted!

  • Lifetime Qt Champion

    @m_andrej said:


    Im not sure u can override it as such.

    Its meant for support for higher res
    screen which will be better supported in Qt 5.6.

    Your use case sounds like you want to have a design where
    all MUCH bigger than it normally would. ?

  • @mrjj said:

    Your use case sounds like you want to have a design where
    all MUCH bigger than it normally would. ?

    I don't understand your question.

  • Lifetime Qt Champion

    ok. sorry if unclear.

    Normally QScreen::devicePixelRatio() is used to scale the size of buttons etc
    so on high res screens they do not become way to small.

    It sounds to me that you are looking for a solution to scale whole GUI so its
    much bigger than a normal desktop app would have it so they can be seen
    from further away ?

  • Yes, I want to make the whole GUI approximately twice as big. Not just text, but also buttons etc.

    If QScreen::devicePixelRatio() isn't the way to go, is it possible to adjust the size of controls by using Qt Style Sheets?

    My UI isn't so rich, contains just a couple of repeating widgets (buttons, tab bar, line edits), so I could just add some code to style sheet for each control type.

  • Lifetime Qt Champion

    Ok. i understand.

    Have you used layouts for the GUI?
    So it already scales to mainwindow?

    Also, must it support many different screen sizes/resolution or
    you know before hand what the target screen will be ?

    I think style sheet could work. However some controls might change the look when
    you apply style sheet.

    Could u show an image of the interface?
    maybe a easy way was just to travel all Widgets and scale by some factor.

  • I did it with stylesheets like this:

    QPushButton { 
    min-height: 40px

  • Lifetime Qt Champion

    Ok. very simple then. :)

Log in to reply