Results 1 to 12 of 12

Thread: QwtPlot - Changing Title fonts

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QwtPlot - Changing Title fonts

    The answer to this may seem completely obvious - when I see it...

    How does one change the Font used by QwtPlot to display the Graph and Axis titles?

    It seems as if there should be a setAxisTitleFont() and setTitleFont()?

    QwtPlot::initPlot() does:
    d_data->lblTitle->setFont(QFont(fontInfo().family(), 14, QFont::Bold));

    but I don't want to edit the source and rebuild the library...

    Thanks!

  2. The following user says thank you to MrGarbage for this useful post:

    TheGhost (4th January 2012)

  3. #2
    Join Date
    Apr 2007
    Posts
    5
    Thanks
    3
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Are these what you are looking for?
    void QwtPlot::setTitleFont ( const QFont & f )
    void QwtPlot::setAxisTitleFont ( int axis, const QFont & f )

    Best.

  4. #3
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Those are exactly what I'm looking for.

    Where are they?

    I don't see them in the qwt doc or my qwt classes.

    I have qwt-5.0.0rc1 - Windows platform.

  5. #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: QwtPlot - Changing Title fonts

    Title and axes are QWidgets. You can assign them a QFont simply by using QWidget::setFont: f.e plot->titleLabel()->setFont(...).

    Also note, that Qwt uses QwtText objects for all of its label. A QwtText can have its own font, that is used instead of the widget font.
    So another option is:

    QwtText title("...");
    title.setFont(...);
    plot->setTitle(title);

    HTH,
    Uwe

  6. The following 3 users say thank you to Uwe for this useful post:

    Eos Pengwern (30th November 2009), rawfool (25th April 2012), TheGhost (4th January 2012)

  7. #5
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Is there a way that I can control the title font size, though?

    Qt allows the font to be set for a Widget, but greater levels of control require the use of style sheets. Qwt, by default, seems to use a very large version of the system font for the axis titles, and in my GUI (where there's limited space) that causes the plot itself to be made tiny.

    Can I force Qwt to print titles in the same font size as the rest of the widget?

  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: QwtPlot - Changing Title fonts

    The size is an attribute of a QFont. How to assign a QFont is explained above.

    Uwe

  9. #7
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Quote Originally Posted by Uwe View Post
    The size is an attribute of a QFont. How to assign a QFont is explained above.

    Uwe
    But in that case, setting the plot font to the same font as the rest of the widget, for example by:

    Qt Code:
    1. myPlot-> axisTitle(QwtPlot::xBottom).setFont(this -> font());
    To copy to clipboard, switch view to plain text mode 

    ... should result in the font size, as well as the font style, being synchronised. My axes titles are still in a much bigger font than everything else, however.

    What am I missing?

  10. #8
    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: QwtPlot - Changing Title fonts

    QwtPlot::axisTitle() is a getter and it doesn't make much sense to assign something to an object, that is returned by value.

    Better do something like this:

    Qt Code:
    1. QwtText title("BlaBla");
    2. title.setFont(QFont("Helvetica", 20));
    3. plot->setAxisTitle(QwtPlot::yLeft, title);
    To copy to clipboard, switch view to plain text mode 

    Uwe

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

    Momergil (10th November 2013)

  12. #9
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Fantastic, that works! Thank you very much.

  13. #10
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    I've an additional question:
    how it is possible to change a plot legend font size? and, if possible, the dash size indicating the curve color?
    thanks

  14. #11
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot - Changing Title fonts

    Isn't that a different question?

    Ressurecting so old thread isn't the best idea.
    Just create new thread so others can find it as well instead of using semi-related subject.

  15. #12
    Join Date
    Apr 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QwtPlot - Changing Title fonts

    Sorry,
    I've done it only beacause I've seen that somebody else did it before me (2007-2009)
    thanks for the advice.

Similar Threads

  1. Replies: 2
    Last Post: 12th April 2007, 12:11

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.