Results 1 to 3 of 3

Thread: Changing the font size and the color of QwtPlot scale labels

  1. #1
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Changing the font size and the color of QwtPlot scale labels

    Hello!

    I would like to know how do one change the Font (particularly the font size) of a QwtPlot's axis labels. Now notice I'm not talking here about the size of a QwtPlot Title, neither am I talking about the size of the title of the axis; I'm talking about the numbers that are displayed in the axis (0, 100,200, etc.). I just can't find the function to change that.

    I would also like to change the color of the axis; for not it's white while the QwtPlot is with black background, and I would like to change the color to black when I put the background to white. I couldn't find the function for that either.

    Any help would be appreciated.

    Momergil
    May the Lord be with you. Always.

  2. #2
    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: Changing the font size and the color of QwtPlot scale labels

    The colors of the axes depends on the palette of the scale widget: QPalette::Text is used for the labels, QPalette::Foreground ( = QPalette::WindowText ) for ticks and backbone.
    You can overrule the widget palette by overloading QwtAbstractScaleDraw::label(), where you can set individual colors for each tick label.

    For your use case I would simply do something like "plot->setPalette( Qt::darkGray );". The constructor of QPalette will create colors with good contrasts and all scale widgets inherit the palette from the plot.

    Concerning the font of the tick labels: "plot->axisWidget( ... )->setFont( ... );" Note, that the font can also be overruled in a similar way like the colors.

    Uwe

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

    Momergil (4th December 2014)

  4. #3
    Join Date
    Jun 2011
    Location
    Porto Alegre, Brazil
    Posts
    482
    Thanks
    165
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Changing the font size and the color of QwtPlot scale labels

    Hello Uwe! Thanks for the reply!

    Now what you sad is what I was looking for - but it didn't work =T Or at least no properly...

    Regarding the color, I'm being unable to change it neither by setting the scale widget's palette, nor by the general QwtPlot::setPalette(). The graph remains as it is. Any suggestions?

    Concerning the font tick labels, the suggested code

    Qt Code:
    1. QFont font = harmonicsGraph->axisWidget(QwtPlot::yLeft)->font();
    2. font.setPointSize(50);
    3. harmonicsGraph->axisWidget(QwtPlot::yLeft)->setFont(font);
    To copy to clipboard, switch view to plain text mode 

    doesn't work in the plot's constructor, only when the showEvent() is called (actually it doesn't work neither in the plot's constructor, nor in its parent's constructor, but in its parent's showEvent()). Was that supposed to happen? And, of course, the general setPalette doesn't work when inside the showEvent() and axis specific setPalette makes the axis dissapear =T.

    Any suggestions on what may be happening of wrong?


    Added after 1 7 minutes:


    BTW, how to change the font and color size for QwtPolarPlot? I noticed that axisWidget() doesn't exist for that class.
    Last edited by Momergil; 4th December 2014 at 14:31.
    May the Lord be with you. Always.

Similar Threads

  1. Space between scale and labels in qwtPLot
    By hassinoss in forum Qwt
    Replies: 3
    Last Post: 20th May 2014, 07:41
  2. Replies: 1
    Last Post: 30th March 2012, 17:46
  3. QLabel Font size is not changing???
    By Gokulnathvc in forum Newbie
    Replies: 4
    Last Post: 22nd March 2011, 12:17
  4. Qt Designer Platform specific font size for labels
    By abey in forum Qt Tools
    Replies: 0
    Last Post: 16th February 2011, 17:21
  5. How to re-scale or changing the size of a QGrapicsScene
    By KristianKarl in forum Qt Programming
    Replies: 2
    Last Post: 9th August 2010, 18:34

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.