Results 1 to 5 of 5

Thread: Increase font size globally (and proportionally)

  1. #1
    Join Date
    Jul 2015
    Posts
    52
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Increase font size globally (and proportionally)

    My application has two 'modes' of functioning, touchscreen and desktop. For the touchscreen mode, I would need to make everything bigger: fonts, icons, buttons, etc. Is there a way to achieve that?

    I have a slider that could change the stylesheet of the application, but I don't know how to make everything scale proportionally. I've successfully changed a checkbox, icon size and font size of a QListView by changing the stylesheet according to a slider value, but I actually would need to make those changes everywhere in the application.

    If not through a slider, making two fixed configurations would work too, but I don't know how to change the base font size globally so that everything is proportional to this base font.

  2. #2
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Increase font size globally (and proportionally)

    You could apply the stylesheet to the whole application by using QApplication's setStyleSheet(const QString & sheet) method.

    Please check:
    http://stackoverflow.com/questions/1...-sheet-loading

  3. #3
    Join Date
    Jul 2015
    Posts
    52
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Increase font size globally (and proportionally)

    Good hint, Charvi.

    I have an assert error when I add

    app.setStyleSheet("QWidget{font-size:30px;}");

    at ASSERT: "calledEmitUpdated" in file graphicsview\qgraphicsscene.cpp, line 467

    What else other than QWidget should I use? Maybe QLabel is enough for text, but I would have to change also icon size and, also, slider size (!). How could I do that?

    The problem with that approach is that the fonts are all set to those 30px, while in my application I have different sizes for different things. I guess the only solution is to make every font policy I set relative to that one to have different sizes, manually.

    I'd have to add an icon-size as well.


    Added after 15 minutes:


    Setting the StyleSheet on the MainWindow solves the assert issue, and since I have all the hierarchy parented, using QWIdget font-size works.

    The only trouble then is that all proportions are lost.
    Last edited by quimnuss; 3rd September 2015 at 11:21.

  4. #4
    Join Date
    Jul 2015
    Posts
    26
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Increase font size globally (and proportionally)

    you can do the following:
    QFont new_font = app.font();
    new_font.setPointSize( int ** ); //your option
    new_font.setWeight( int ** ); //your option
    app.setFont( new_font );

  5. #5
    Join Date
    Jul 2015
    Posts
    52
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Increase font size globally (and proportionally)

    Nice to know!

    It would have the same problem as the other approaches but circumvents the use of stylesheets (If I didn't want to).

    Cheers

Similar Threads

  1. Not able to increase font size for QTextEdit
    By shyamsundar1982 in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd March 2015, 08:38
  2. Replies: 1
    Last Post: 30th March 2012, 17:46
  3. Globally reset my font sizes to default?
    By scott_hollen in forum Qt Programming
    Replies: 1
    Last Post: 2nd November 2011, 00:26
  4. Font size increase in QtableWidget
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2009, 15:51
  5. How to increase font size in arm target
    By soumya in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 2nd September 2009, 06:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.