Results 1 to 5 of 5

Thread: Font size for QwtPlot title?

  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Font size for QwtPlot title?

    Hi,

    i'm testing this code with the "friedberg" example and latest Qwt version:

    in plot.cpp after line 70 add a qDebug() line

    Qt Code:
    1. setTitle( "Temperature of Friedberg/Germany" );
    2. qDebug() << title().font(); // NEW
    To copy to clipboard, switch view to plain text mode 

    The output is:

    QFont( "MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" )

    But the font size of the plot title is never 8.25.

    Here
    https://msdn.microsoft.com/de-de/lib...(v=vs.85).aspx
    you can find, that "MS Shell Dlg 2 simply uses the Tahoma font regardless of language.".

    I rebuild the title in Word Pad and the font size must be 14.

    Fontsize.jpg

    What's is going wrong here? Why is the size wrong of the returned font by title().font() ? Guess it is a bug.

    Thx
    Last edited by HappyCoder; 20th January 2016 at 17:27.

  2. #2
    Join Date
    Jan 2016
    Posts
    4
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Font size for QwtPlot title?

    What do you want?
    for changing your title font, color, ..... you can use QwtText like this:

    Qt Code:
    1. QFont font14;
    2. font14.setPointSize(14);
    3. QwtText title;
    4. title.setText("Your Title");
    5. title.setFont(font14);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Font size for QwtPlot title?

    Quote Originally Posted by KT_HG View Post
    What do you want?
    I wrote it: Why is the size wrong of the returned font by title().font() ?

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,253
    Thanked 860 Times in 809 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Font size for QwtPlot title?

    Maybe because Qt uses the "closest matching installed font" only ( see the QFont docs ) ?

    Uwe

  5. #5
    Join Date
    Jan 2020
    Posts
    1
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Font size for QwtPlot title?

    Quote Originally Posted by HappyCoder View Post
    I wrote it: Why is the size wrong of the returned font by title().font() ?
    I had this same question, and could not make sense of Uwe's answer here. The cause is that there are two different QFonts that apply to the title - one from the QwtText returned from QwtPlot::title() and a different one from the QwtTextLabel returned from QwtPlot::titleLabel().

    As HappyCoder demonstrated, plot->title().font() returns:

    QFont( "MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0" )

    Which you can verify is incorrect/not-in-use by assigning this back to the title by plot->title().setFont(), which results in the font visibly shrinking.

    So, instead, plot->titleLabel()->font() gives you the actual initial/default font in the correct size, which returns:

    QFont( "MS Shell Dlg 2,14,-1,5,75,0,0,0,0,0" )

    For reference, I found this comment/thread that led me to this answer: https://www.qtcentre.org/threads/673...5432#post35432

Similar Threads

  1. Replies: 2
    Last Post: 4th December 2014, 13:23
  2. qwtPlot legend font size
    By Narciso in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2012, 10:51
  3. Replies: 1
    Last Post: 30th March 2012, 17:46
  4. Title with two different font sizes
    By aloehr in forum Qwt
    Replies: 0
    Last Post: 9th September 2011, 13:25
  5. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 09:02

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.