Results 1 to 4 of 4

Thread: Draw the tic label of a Qwt3D plot in two separate lines

  1. #1
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Draw the tic label of a Qwt3D plot in two separate lines

    Hi guys,

    Thanks in advance. I'm triying to show the lable of the tics in a Qwt3D in two lines. To do that , I needed to create a new class that inherits from LineraScale class, and then overwrite the ticLabel member function.

    Header class
    Qt Code:
    1. class myScale: public LinearScale
    2. {
    3. public:
    4. Scale* clone() const {return new myScale();}
    5. QString ticLabel(unsigned int idx) const;
    6. };
    To copy to clipboard, switch view to plain text mode 

    The cpp file
    Qt Code:
    1. QString myScale::ticLabel(unsigned int idx) const
    2. {
    3.  
    4. return QString("This is 1st line" + "\n" + "this should be the 2nd one" );
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    But when the plot is shown, the result appears in the same line "This is the 1st line this should be the 2nd one".
    It is possible to do that with QwtPlot, but with this module, the "\n" has no effect.

    Further info: To plot the label , internally the Qwt3D uses a Qwt3D::Label, and it sets the string with the memeber function void setString ( QString const & s ) // Sets the labels string For unicode labeling ( QChar(0x3c0) etc.) please look at www.unicode.org.

    I dont know if the problem is this conversion or if the unicode labeling has any other simbol to indicate the new line.

    Any idea?

    Thanks!!
    Last edited by locke; 28th May 2010 at 12:11.

  2. #2
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    7
    Thanked 5 Times in 4 Posts

    Default Re: Draw the tic label of a Qwt3D plot in two separate lines

    The QwtPlot3d libs don't support this at the moment. I am also using these libs and have tried this with the 0.3.0 dev branch too and its not possible.

    I would recommend getting up to speed with the new improved API in 0.3.0 since it is MUCH better at displaying axis labels on X11/Linux. If you don't use X11/Linux then its still worth working out the new APIs so you don't have to rework your code when it gets released.

    Hope this helps (a little)

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

    locke (1st June 2010)

  4. #3
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Draw the tic label of a Qwt3D plot in two separate lines

    Ok, thanks.

    I was triying to modify the Qwt3D plot code, did you look at it?

    There is a header called, qwt3d_portability.h where a this variable is defined:
    Qt Code:
    1. const Qt::TextFlag SingleLine = Qt::TextSingleLine;
    To copy to clipboard, switch view to plain text mode 

    An then, in qwt3d_label.cpp this variable is used:
    Qt Code:
    1. ....
    2.  
    3. QRect r = QRect(QPoint(0,0),fm.size(Qwt3D::SingleLine, text_));
    4.  
    5. .....
    To copy to clipboard, switch view to plain text mode 

    In oder to set the rectangle of the text label in a single line. I tried to replace this flag with another one,in order to avoid the single line restiction, but It doesn't work?

    Did you also try this approach?

    Thanks

  5. #4
    Join Date
    Sep 2009
    Posts
    57
    Thanks
    7
    Thanked 5 Times in 4 Posts

    Default Re: Draw the tic label of a Qwt3D plot in two separate lines

    Sorry, no I just eat the porridge and wait for bug fixes :-)

Similar Threads

  1. Draw lines in a QGridLayout
    By Eos Pengwern in forum Qt Programming
    Replies: 0
    Last Post: 28th April 2010, 02:27
  2. plot with hor. lines and text
    By hugo vanwoerkom in forum Qwt
    Replies: 2
    Last Post: 10th March 2010, 18:00
  3. How to draw some points and lines?
    By luffy27 in forum Qt Programming
    Replies: 1
    Last Post: 24th November 2006, 17:47
  4. How to draw lines with the right width?
    By albanelporto in forum Qt Programming
    Replies: 3
    Last Post: 22nd November 2006, 12:51

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.