Results 1 to 6 of 6

Thread: X axis tick label - font size

  1. #1
    Join Date
    Feb 2012
    Posts
    9
    Thanks
    3

    Default X axis tick label - font size

    Hi All,

    I would like to change the font size of the x axis tick label in the exmaple of "friedberg".

    Any suggestion or advice would be really appreciated.

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Thanks
    20
    Thanked 28 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: X axis tick label - font size

    Use void QwtPlot::setAxisFont ( int axisId,const QFont & f ) to set axis font.
    For different labels use your own QwtScaleDraw.
    1. Inherit from QwtScaleDraw and overload the virtual function QwtText QwtScaleDraw::label(double v) const
    2. Return the label with the type of font, size etc. from the function.
    3. Use QwtPlot::setAxisScaleDraw to set the scale for the axis in Qwtplot inherited class constructor.

  3. The following user says thank you to pkj for this useful post:

    junhonguk (26th April 2012)

  4. #3
    Join Date
    Apr 2012
    Location
    Paris
    Posts
    11
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: X axis tick label - font size

    For axis font like said pkj use QwtPlot::setAxisFont( int axisId,const QFont & f ).

    And for scale labels, use the same method as the title (it's more simple...):
    Qt Code:
    1. QwtText scaleLabel = QwtText("...");
    2. scaleLabel.setFont(...);
    3. plot->setAxisTitle(QwtPlot::yLeft, scaleLabel);
    To copy to clipboard, switch view to plain text mode 


    Added after 6 minutes:


    I have a question more general on Qwt font management:
    Why Qwt does not use a relative font definition with the QApplication::font() ?
    I think it's a more useful managment...
    Last edited by Guiom; 26th April 2012 at 14:22.

  5. The following user says thank you to Guiom for this useful post:

    junhonguk (26th April 2012)

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

    Default Re: X axis tick label - font size

    Quote Originally Posted by Guiom View Post
    Why Qwt does not use a relative font definition with the QApplication::font() ?
    It does - Qwt widgets work exactly like any other widget how to find the font for drawing itsself.

    But this doesn't work when you need more than one font in one widget ( f.e QwtScaleWidget needs 2 - or even more - different fonts for title and tick labels ) or the element is no widget at all.
    But even a QLabel takes the widget font as default only, when no font is explicitely assigned - f.e embedded in rich text, where you could use different fonts for each letter.

    Uwe

  7. #5
    Join Date
    Apr 2012
    Location
    Paris
    Posts
    11
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: X axis tick label - font size

    Quote Originally Posted by Uwe View Post
    It does - Qwt widgets work exactly like any other widget how to find the font for drawing itsself.
    But in QwtPlot::initPlot the tilte is initialized with an absolute size...
    Qt Code:
    1. d_data->lblTitle->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
    To copy to clipboard, switch view to plain text mode 

    Same in QwtPlot::initAxesData()
    Qt Code:
    1. QFont fscl( fontInfo().family(), 10 );
    2. QFont fttl( fontInfo().family(), 12, QFont::Bold )
    To copy to clipboard, switch view to plain text mode 

    If my application is defined with a font size to 8, plot title, scale label and scales are very big !!

  8. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,309
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: X axis tick label - font size

    Ah o.k - now I got what you meant.

    But whatever ( or no ) default setting is implemented - it will be overwritten in almost every application. Nobody wants to have the same fonts for titles and tick labels.
    Taking this into count I agree it might be better to do a useless, but "logical" implementation instead of trying to please a minority.

    Uwe

Similar Threads

  1. Y Axis tick labels cut off on left
    By rbergeron in forum Qwt
    Replies: 2
    Last Post: 4th November 2011, 15:29
  2. Replies: 2
    Last Post: 29th September 2011, 14:10
  3. How to resize label font to fit size
    By P@u1 in forum Qt Programming
    Replies: 2
    Last Post: 19th July 2011, 00:07
  4. y-axis tick labels trimmed
    By gib in forum Qwt
    Replies: 2
    Last Post: 2nd April 2010, 06:19
  5. changing QLabel font size(label created on the graphicsView)
    By maverick_pol in forum Qt Programming
    Replies: 11
    Last Post: 17th August 2007, 09:36

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.