Results 1 to 3 of 3

Thread: Font scaling and custom QFileDialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2019
    Location
    Lyon, France
    Posts
    18
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Font scaling and custom QFileDialog

    Hi!

    I have two question and thought it would be better if I ask them in the same thread, hope it's ok!


    1. Font scaling with resolution
    Is it possible to assign different font size depending of the screen resolution? (not when resizing window)
    I was thinking of detecting the screen size when launching the application and then attributing a correct font size depending of the resolution. But I'm afraid this will mess with the layouts and other elements, like the font overflowing neighboring elements, or words being cut in half...
    I use a fairly large screen myself, but some of my users use really giant screens and the fonts are quite tiny.


    2. Custom layout for QFileDialog
    Is it possible to just change the position of certain elements in the QFileDialog?
    I'm in Linux and I want the "Open" button on the bottom right and the file extension on top.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font scaling and custom QFileDialog

    Quote Originally Posted by Thibaut View Post
    1. Font scaling with resolution
    Is it possible to assign different font size depending of the screen resolution? (not when resizing window)
    I was thinking of detecting the screen size when launching the application and then attributing a correct font size depending of the resolution. But I'm afraid this will mess with the layouts and other elements, like the font overflowing neighboring elements, or words being cut in half...
    I use a fairly large screen myself, but some of my users use really giant screens and the fonts are quite tiny.
    QApplication::setFont

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Font scaling and custom QFileDialog

    1. Font scaling with resolution
    Keep in mind that on Windows and maybe on other OS, users can change font magnification at the OS level. On Windows, Qt abides by this, so a 10 pt font at 125% magnification is equivalent to a 12.5 pt font at 100%. I have seen this cause clipping and other layout issues if other widgets (like QLabel) have size constraints set which limit their expansion. If no constraints are set, then with magnification the widgets will expand to hold the full text.

    2. Custom layout for QFileDialog
    Is it possible to just change the position of certain elements in the QFileDialog?
    I'm in Linux and I want the "Open" button on the bottom right and the file extension on top.
    On some OS, the OS native file dialog is used instead of a Qt-specific one, so it may not be possible to customize. You may be able to override this using QFileDialog::setOptions() before the dialog is shown on screen or derive a custom dialog from QFileDialog. To get to the individual widgets inside the Qt-based QFileDialog, you will need to call QFileDialog::layout() (inherited from QWidget) and then try to figure out which widget corresponds to the things you want to modify.

    Sounds like more trouble than it is worth and a likely source of confusion to users who are used to seeing a particular style on their OS.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Font size or DPI scaling dimension?
    By piccoloqtino in forum Newbie
    Replies: 0
    Last Post: 22nd June 2018, 02:31
  2. how to set custom font to qlabel
    By binary001 in forum Newbie
    Replies: 2
    Last Post: 8th March 2015, 13:40
  3. QFileDialog custom columns
    By filnik in forum Qt Programming
    Replies: 3
    Last Post: 6th March 2012, 14:51
  4. QFileDialog custom acceptance condition
    By akos.maroy in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2011, 13:35
  5. QLabel - auto font scaling possible?
    By Byngl in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2007, 17:50

Tags for this Thread

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.