Results 1 to 6 of 6

Thread: Is there a way to draw margin a QwtText around?

  1. #1
    Join Date
    May 2013
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Is there a way to draw margin a QwtText around?

    I would like to draw margin a QwtText around, between the text and the border line.
    I want to use it in QwtPlotMarker.

    Please help me. Thanks!

  2. #2
    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: Is there a way to draw margin a QwtText around?

    Are you talking about shifting the position of a marker label, when it comes to close to the canvas border ?

    Uwe

  3. #3
    Join Date
    May 2013
    Posts
    4
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Is there a way to draw margin a QwtText around?

    Hi Uwe!

    I want to initialise a QwtPlotMarker by a QwtText wich has border ( the border pen has been set).
    I would like to see a margin between the text and the borderline when I shows this QwtPlotMarker. But now the border are close to the border.
    Is there any way to draw margin in a QwtText?



    QwtPlotMarker* m_pDescription;
    QwtText m_descriptionText;
    ...
    m_pDescription = new QwtPlotMarker();
    m_pDescription->attach( ui->pltCurve ); // This is the QwtPlot
    ...
    QPen tmpPen = m_descriptionText.borderPen();
    tmpPen.setStyle( Qt::SolidLine );
    tmpPen.setWidth( 1 );
    m_descriptionText.setBorderPen(tmpPen);
    ...
    m_pDescription->setValue( pos ); // Where pos is a QPosF
    m_descriptionText.setText( txt ); // Where txt is a QString
    m_pDescription->setLabel( m_descriptionText );
    m_pDescription->show();

    m_pDescription->setLabel( m_descriptionText );


    Sorry, but my english not very good.
    Thanks for your help!

    KoVi

  4. #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: Is there a way to draw margin a QwtText around?

    In general a QwtText is painted using QwtText::drawText( QPainter *, const QRectF &). So what you can do is to overload QwtPlotMarker::drawLabel() calculating a different ( = larger ) rectangle.

    Uwe

  5. #5
    Join Date
    Mar 2011
    Posts
    25
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is there a way to draw margin a QwtText around?

    Hi!

    Is it possible to add a custom margin between QwtText's inner border and the text itself?
    Otherwise it looks quite ugly when borderPen and borderRadius are defined.

    I mean something like QwtText::setInnerMargin(2) for example.
    Thanks!

  6. #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: Is there a way to draw margin a QwtText around?

    All you can do is the derive from QwtTextEngine overloading QwtTextEngine::textMargins, register it with QwtText::setTextEngine and use this special engine for the texts, where you need the extra margins.

    Of course this is only a workaround and there should be something like QwtText::setInnerMargin().

    Uwe

Similar Threads

  1. QwtText background padding
    By Maximus2 in forum Qwt
    Replies: 9
    Last Post: 6th December 2018, 08:36
  2. Replies: 0
    Last Post: 21st November 2013, 07:39
  3. Replies: 2
    Last Post: 16th March 2012, 07:55
  4. Replies: 10
    Last Post: 11th February 2011, 00:31
  5. How to Set margin
    By suresh in forum Newbie
    Replies: 1
    Last Post: 5th October 2006, 07:13

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.