Results 1 to 2 of 2

Thread: QSlider Iteration Misses Sample Data on QCustomPlot

  1. #1
    Join Date
    Jan 2021
    Posts
    8
    Qt products
    Qt5
    Platforms
    Windows

    Default QSlider Iteration Misses Sample Data on QCustomPlot

    0


    I use QSlider and QCustomPlot widgets together in the project. It works ok generally but when I iterate QSlider once ( single iteration ) after zooming on QCustomPlot a few times( range size decreases), some data missed and can not be examined in detail. Lets say previous x axis range (10:20:000 – 10:20:300), the next range after iteration becomes (10:20:460 - 10:20:760 ). So, 160 miliseconds could not be seen. In this context, my implementation is as follows;
    Qt Code:
    1. connect(ui->horizontalScrollBar, SIGNAL(valueChanged(int)), this, SLOT(horzScrollBarChanged(int)));
    2. connect(ui->plot->xAxis, SIGNAL(rangeChanged(QCPRange)), this, SLOT(xAxisChanged(QCPRange)));
    3.  
    4.  
    5. void MainWindow::horzScrollBarChanged(int value)
    6. {
    7. if (qAbs(ui->plot->xAxis->range().center()-value/100.0) > 0.01) // if user is dragging plot, we don't want to replot twice
    8. {
    9. ui->plot->xAxis->setRange(value/100.0, ui->plot->xAxis->range().size(), Qt::AlignCenter);
    10. ui->plot->replot();
    11. }
    12. }
    13.  
    14. void MainWindow::xAxisChanged(QCPRange range)
    15. {
    16. ui->horizontalScrollBar->setValue(qRound(range.center()*100.0)); // adjust position of scroll bar slider
    17. ui->horizontalScrollBar->setPageStep(qRound(range.size()*100.0)); // adjust size of scroll bar slider
    18. }
    To copy to clipboard, switch view to plain text mode 

    Could you please help about this problem ?
    Thanks in advance for your replies..

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,938
    Thanks
    276
    Thanked 803 Times in 792 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: QSlider Iteration Misses Sample Data on QCustomPlot

    Not sure why, but this post was flagged as "needing moderation". I approved it, but in the meantime also answered in your second post.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 1
    Last Post: 2nd March 2020, 17:11
  2. How to implement Warp7 sample as same as sample in QtWS16
    By nntchau in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 8th December 2017, 08:06
  3. Serial read misses to read data from the serial port
    By mania in forum Qt for Embedded and Mobile
    Replies: 11
    Last Post: 18th August 2014, 08:49
  4. Replies: 16
    Last Post: 27th March 2013, 06:23
  5. Drag and Drop in QGraphicsScene misses items
    By enno in forum Qt Programming
    Replies: 2
    Last Post: 30th August 2009, 15:17

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.