Results 1 to 5 of 5

Thread: yLeft axis constant width

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default yLeft axis constant width

    I made an array (vertically ) of qwtplot that xBottom axis are synchronized ( just like the plot matrix). Now my problem is that yLeft axis values are changing , so the number of digits will shrink and expand in effect this will misallign my xBottom axis.

    My idea of a solution would be to have a constant width on QwtScaleWidget by setting minimumWidth() to something like the width of 6 digits numbers. but this is kinda hacky. Is there an elegant solution to my woes uwe?

    By the way i tried setting QwtScaleWidget's minimumWidth and found that the canvas won't respect QwtScaleWidget.

    scalewidget was overdrawn by the canvas

    baray98

  2. #2
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: yLeft axis constant width

    More debugging showed me that by adjusting scaleDraw to the max width of all yLeft axis will do the trick.. but changes ( or redraw) is not visible until I will resize the widget. I have tried both replot and repaint on each plot and nothing happens.

    Uwe how will i trigger a redraw after changing scaleDraw's minimumExtent ?

    baray98

  3. #3
    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: yLeft axis constant width

    What about QwtPlot::updateLayout() ?

    You can call updateLayout() manually, but it is also called internally for each LayoutRequest event. AFAIR this event is posted by QWidget::updateGeometry(), so I guess you could also do plot->updateGeometry(). Using LayoutRequest events might be preferable as several LayoutRequest can be collected by Qt to a single one.

    Uwe

  4. The following user says thank you to Uwe for this useful post:

    baray98 (23rd April 2010)

  5. #4
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: yLeft axis constant width

    updateLayout will do the trick but not updateGeometry();

    solved

    baray98

  6. #5
    Join Date
    Nov 2012
    Posts
    3
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: yLeft axis constant width

    I am working on the same problem. Why doesn't the canvas respect the axis widget's minimumWidth()? Is this a bug?

    Also, QwtPlot::updateLayout is not a slot, so I can't just do:
    Qt Code:
    1. connect(m_ui->qwtPlot->axisWidget(QwtPlot::yLeft), SIGNAL(scaleDivChanged()),
    2. m_ui->qwtPlot, SLOT(updateLayout()));
    To copy to clipboard, switch view to plain text mode 
    to work around this.


    Added after 1 6 minutes:


    This seems to do the trick:
    Qt Code:
    1. m_ui->qwtPlot->axisWidget(QwtPlot::xBottom)->setMinBorderDist(90, 20);
    2. m_ui->qwtPlot->plotLayout()->setAlignCanvasToScales(true);
    To copy to clipboard, switch view to plain text mode 
    This has some side effects I don't really like (the canvas doesn't stretch to the edge on the top and right) but it helps with a lot of the flickering when axis labels change.
    Last edited by ykozlov; 4th January 2013 at 17:40.

  7. The following user says thank you to ykozlov for this useful post:

    hind (5th July 2016)

Similar Threads

  1. Constant busy cursor when application is run
    By b1 in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 10th January 2010, 22:30
  2. Axis yLeft cuts of numbers
    By sun in forum Qwt
    Replies: 17
    Last Post: 9th October 2009, 22:36
  3. QToolBox width fixed to maximum content width
    By ghorwin in forum Qt Programming
    Replies: 0
    Last Post: 10th July 2009, 10:58
  4. Replies: 1
    Last Post: 28th January 2009, 15:47
  5. How to set QTableView width to width of horizontal header?
    By martinb0820 in forum Qt Programming
    Replies: 0
    Last Post: 2nd December 2008, 21:51

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.