Results 1 to 3 of 3

Thread: QwtScaleWidget: The length of colorbar and backbone are different

  1. #1
    Join Date
    Mar 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default QwtScaleWidget: The length of colorbar and backbone are different

    Hello,

    I am using QwtScaleWidget in a mainwindow to display color bar. The problem is that the color bar is somehow a little bit longer than the backbone of scalewidget's scaledraw at the bottom, when both of their lower boundaries are exactly the same.

    Here is a screenshot: plot.PNG
    My code:
    Qt Code:
    1. colorbar->setColorBarEnabled(true);
    2. QwtInterval zInterval = ... //The zInterval is [2, 79]
    3.  
    4. QwtLinearColorMap *colormap = ...
    5. colorbar->setColorMap(zInterval, colormap);
    6.  
    7. QwtScaleDiv scaleDiv(zInterval.minValue(), zInterval.maxValue());
    8. QList<double> majorTick;
    9. for (double i = zInterval.minValue(); i <= zInterval.maxValue(); i += gap) { //gap is 8 here
    10. majorTick.append(i);
    11. }
    12. scaleDiv.setTicks(QwtScaleDiv::MajorTick, majorTick);
    13. colorbar->setScaleDiv(scaleDiv);
    To copy to clipboard, switch view to plain text mode 

    I want to align the bottom of the color bar with the backbone(i.e. the first tick of the scale). Is there any way to do this?

    Thanks for your help!

  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: QwtScaleWidget: The length of colorbar and backbone are different

    Your code works on my box when doing it in the setup process of a plot. So my guess is, that your code runs in a specific situation, where no layout recalculation happens.
    If you can provide a minimal demo demonstrating the problem I will have a look at it.

    Uwe

  3. #3
    Join Date
    Mar 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtScaleWidget: The length of colorbar and backbone are different

    Thanks for Uwe's reply.

    I've accidentally fixed the problem by adding this code:
    Qt Code:
    1. colorbar->setBorderDist(10, 10);
    To copy to clipboard, switch view to plain text mode 

    Result: plot.jpg

    It looks good for me and I won't go further with the issue because the function of my code is experimental and very initial.
    Last edited by Ara; 15th March 2021 at 05:33.

Similar Threads

  1. QwtDial backbone radius problem
    By cmschroeder in forum Qwt
    Replies: 3
    Last Post: 7th November 2017, 08:18
  2. Replies: 7
    Last Post: 10th July 2013, 14:32
  3. QGraphicsView & QwtScaleWidget
    By fruzzo in forum Qwt
    Replies: 1
    Last Post: 28th September 2011, 19:50
  4. Replies: 1
    Last Post: 19th July 2011, 08:32
  5. Stand-alone colorbar (no canvas)
    By llamas in forum Qwt
    Replies: 3
    Last Post: 20th August 2008, 09:47

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.