Results 1 to 6 of 6

Thread: QwtPlotItem::setZ() isn't working correctly

  1. #1
    Join Date
    Mar 2018
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QwtPlotItem::setZ() isn't working correctly

    Hi everybody, hi Uwe.

    I'm using a QwtPlot (based on the oscilloscope example) to show live data with one or more QwtPlotCurve. Optionally there are markers (QwtPlotMarker) and one QwtPlotTextLabel shown in the plot.
    The z-order (QwtPlotItem::setZ()) for the curves is 1, for the QwtPlotMarker z is 2 and 3 for the QwtPlotTextLabel.
    The z-order for the marker and the label is working correctly (the label is always on top of the marker), but the curves are sometimes on top of everything and sometimes everything is shown in the right order. The curves are updated using QwtPlotDirectPainter::drawSeries().

    Code for the plot: https://github.com/knarfS/smuview/bl.../plot/plot.cpp

    Is this a bug or am I doing something wrong?

    Thanks,
    Frank


    Added after 55 minutes:


    Sorry but I totally forgot:
    When I activate replot() in Plot::update_curves() (https://github.com/knarfS/smuview/bl.../plot.cpp#L686), the z-order is working, but the curves starts to flicker when there are ~500 samples shown...
    Last edited by knarfS; 22nd November 2019 at 15:19.

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

    Default Re: QwtPlotItem::setZ() isn't working correctly

    Quote Originally Posted by knarfS View Post
    The curves are updated using QwtPlotDirectPainter::drawSeries().
    This is a specific hack that allows to draw incrementally on top of the existing content without having to repaint the rest.
    So yes this will break the z-order and there is no way to get around it.

    Uwe

  3. #3
    Join Date
    Mar 2018
    Posts
    5
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: QwtPlotItem::setZ() isn't working correctly

    Hi Uwe.

    Ok, that makes sense.
    Is there another possibility to live plot a large number of data points with some sort of a z-order?

    Frank

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

    Default Re: QwtPlotItem::setZ() isn't working correctly

    One approach would be to draw your curve to a pixmap and overload QwtPlot::drawItems to bring the pixmap into the game.

    But I would check first if it is possible to speed up rendering itself:

    • try to run on a hardware accelerated graphics backend.
    • don't use antialiasing or pens with a width > 1
    • maybe QwtPlotCurve::FilterPointsAggressive ( Qwt >= 6.2 ) can be used
    • ...


    I would also decouple sample and replot rates. Usually it doesn't make much sense to replot more than a few times per second.

    Uwe

  5. #5
    Join Date
    Dec 2011
    Posts
    60
    Thanks
    12
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QwtPlotItem::setZ() isn't working correctly

    Quote Originally Posted by Uwe View Post
    This is a specific hack that allows to draw incrementally on top of the existing content without having to repaint the rest.
    So yes this will break the z-order and there is no way to get around it.

    Uwe
    Oh no! Uwe, is this also the case when using a QwtPlotCurve? I'm having the same issue of QwtPlotItems being below the plot regardless of the QwtPlotItem::setZ().

    (However, I'm following your itemeditor example, so when I move the QwtPlotItem I create a temporary QwtWidgetOverlay and this places the moving item ABOVE the plot, as I want.)

    So, with QwtPlotCurve does one still need to render to a custom pixmap to fix the z-order, or are there other workarounds, such as with QwtWidgetOverlay or something else?

    EDIT: Aha! I got it to work by using QwtPlotCurve::setZ(0). Setting QwtPlotItem::setZ() seems to have no effect in relation to the z height of the curve.
    Last edited by alketi; 31st January 2022 at 18:03.

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

    Default Re: QwtPlotItem::setZ() isn't working correctly

    There is no specific QwtPlotCurve::setZ() - it is exactly the same call as QwtPlotItem::setZ().

    Uwe

Similar Threads

  1. QProcess not working correctly
    By m_bishop in forum Qt Programming
    Replies: 2
    Last Post: 28th May 2013, 17:36
  2. stylesheet not working correctly
    By melody:p in forum Qt Programming
    Replies: 5
    Last Post: 3rd September 2012, 06:38
  3. setTabStopWidth not working correctly?
    By Kyosaur in forum Qt Programming
    Replies: 3
    Last Post: 9th January 2012, 15:16
  4. Drop not working correctly
    By rippa in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2008, 16:13
  5. renderText is not working correctly
    By validator in forum Qt Programming
    Replies: 3
    Last Post: 27th May 2008, 17:55

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.