Important: Please read the Qt Code of Conduct -

Qt Quick Application font size increased when run as super user in Ubuntu

  • Hi Everyone,

    I have developed one Qt Quick Application and it's working fine when I am running as normal user.
    But, same code is increasing the font size when I am running as super user.
    What should be the reason for this changes?

    Is anyone faced same kind of issue?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Are you using sudo to run your application as super user ?

    I remember from old time that there where some distributions that had some clear visual changes when running something as a super user so you would take extra care before doing something that would break your machine.

  • @SGaist Yes, I am using sudo to run your application as super user.
    Then how to prevent the changes in super user. Because, I have to run my application in super user mode only.
    It changes approx 5 to 10 font size and result is so ugly.

  • Are you explicitly setting the font size? I am guessing root is not setup with defaults like a normal user would have. root is not running the xsession so nothing was ever setup for root user.

    I don't think its a good idea to run the whole app as root. You should be looking at elevating privileges for the tasks your program runs. One way is to spin off tasks using QProcess. There might be other ways. The maintenance tool from Qt does this.

  • Lifetime Qt Champion

    @fcarney is correct here, you should cleanly separate what root shall do and the GUI. Take for example the settings. You can freely change things and for stuff like system clock, you will get a dialog asking for a super user password in order to alter the system.

  • @fcarney Hi fcarney, thanks for commenting.
    In qml file, I have mentioned like this "font.pointSize: 24" in my text.

    In my project, I have other applications also (other than QT application). For that I have to run my entire project in root mode only.
    For this case, what can I do for that font issue?

  • @martiny said in Qt Quick Application font size increased when run as super user in Ubuntu:

    For this case, what can I do for that font issue?

    Also, is the font the same as regular user?
    Try setting a specific font and see if that helps. Also, check DPI for both user types. This could be messing things up. You could also go with fonts being set to pixel size and see if this helps.
    I am not sure how hard this would be, but maybe check out the settings for root vs user. And set settings on root to be a known set of values for window manager / xsession.

  • Can you log into an xsession as root so it sets up the user?

  • @fcarney Hi Fcarney, sorry for delay.
    I have not using any specific fonts. I have tried default theme and font matching between normal user and root user. But, there is no changes.(
    And also I tried Qt examples even in that examples i'm facing same issue. I didn't change anything on the example code.

Log in to reply