Results 1 to 6 of 6

Thread: How to move the title of the xBottm axis to its right end?

  1. #1
    Join Date
    May 2016
    Location
    China,Wuhan
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default How to move the title of the xBottm axis to its right end?

    I'd like to move the xBottom axis's title position in Qwt plot. However, when I try to do that by subclassing QwtScaleWidget, I can not associate it with my plot.
    Since the defualt position of the title of the xBottom axis is in the middle. I'd like to move the title to the right end of the xBottom axis while keeping the text's orientation as the following picture shown.I try to subclass my class(CustomScaleWidget) from QwtScaleWidget and overload its drawTitle() fucntion, and its position moved, but I cannot find any api in qwtplot to associate my class with my qwtplot.Then my CustomScaleWidget is a standalone widget from other widget in the plot.How can I associate it with my plot?Or Is there any other method?Thank u~
    The final position is shown in the picture(beside the xbottom axis's right end,but out of the canvas).
    abc.jpgdef.jpg
    Last edited by daxiong; 3rd August 2016 at 11:18. Reason: updated contents

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to move the title of the xBottm axis to its right end?

    The alignment can be changed this way:

    Qt Code:
    1. QwtText axisTitle( "min" );
    2. axisTitle.setRenderFlags( Qt::AlignRight | Qt::AlignVCenter );
    3. axisTitle.setFont( plot->axisTitle( QwtPlot::xBottom ).font() );
    4. plot->setAxisTitle( QwtPlot::xBottom, axisTitle );
    To copy to clipboard, switch view to plain text mode 
    But this might still not be what you want to have as the title label is aligned to the canvas and its right end is not below the right scale.

    Uwe

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

    daxiong (3rd August 2016)

  4. #3
    Join Date
    May 2016
    Location
    China,Wuhan
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to move the title of the xBottm axis to its right end?

    Yes, that's almostly what I want~As the result is shown in picture.hij.jpg
    Thank u very much, Uwe~~
    However, when I look up the souce file "qwt_plot.cpp" to figure out how it works, I can not find setAxisTitle's implementation.
    In file qwt_plot.h,
    I can see the declaration of void setAxisTitle( int axisId, const QString & );
    But in qwt_plot.cpp,I can not find its implementation.
    Is this part of code not opened or my code is not the latest?

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

    Default Re: How to move the title of the xBottm axis to its right end?

    http://qwt.sourceforge.net/class_qwt...3365558d0303c4 or line 216 in qwt_plot.h of qwt 6.1

    Uwe

  6. #5
    Join Date
    May 2016
    Location
    China,Wuhan
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to move the title of the xBottm axis to its right end?

    Sorry,Uwe,I typed the wrong api:
    void setAxisTitle( int axisId, const QString & );
    should be
    void setAxisTitle( int axisId, const QwtText & );
    I mean I can not find void setAxisTitle( int axisId, const QwtText & );
    's implementation not declaration.
    The downloaded code is qwt-6.1,moreover,
    I find other apis have no implementation: void setAxisMaxMinor( int axisId, int maxMinor );
    int axisMaxMinor( int axisId ) const;
    Their all seems to be attribute setting.But I can not find the responding member varible in qwtplot.

  7. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,277
    Thanked 871 Times in 819 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to move the title of the xBottm axis to its right end?

    Maybe consider to use a better IDE ( I can recommend vi ): implementation can be found in qwt_plot_axis.cpp.

    Uwe

    PS: grep is your friend

Similar Threads

  1. Rotating Y Axis Title
    By bigjoeystud in forum Qwt
    Replies: 3
    Last Post: 9th June 2015, 20:57
  2. How to rotate right axis title?
    By beckjoh in forum Qwt
    Replies: 2
    Last Post: 6th May 2014, 07:12
  3. Axis Title to axis label alignment
    By ROCKSTAR in forum Qwt
    Replies: 0
    Last Post: 5th February 2014, 12:47
  4. How to move items with x axis keep y axis
    By linhdong24 in forum Qt Programming
    Replies: 0
    Last Post: 5th July 2013, 02:39
  5. Set axis title on the right side
    By pospiech in forum Qwt
    Replies: 1
    Last Post: 14th March 2008, 07:26

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.