QwtPlot-resizeEvent Discarding Qualifiers

  • Hi, I'm trying to constrain the proportions of a QwtPlot when resizing the window, but I keep running into this error: passing ‘const QSize’ as ‘this’ argument of ‘void QSize::setHeight(int)’ discards qualifiers

    This is the code I'm using:
    @void QwtPlot::resizeEvent (QResizeEvent * e) {
    int h = e->oldSize().height();
    int w = e->oldSize().width();

    int newW = e->size().width()*h/w;


    I'm not sure if it's strictly and QwtPlot problem or a general problem. I've tried replacing newW with a number (400) but I still got the same problem. What am I doing wrong?


  • Moderators

    You can't set the e->size() property. It's read-only, in effect.

    Perhaps you want to use "QWidget::setMaximumSize()":http://doc.qt.nokia.com/latest/qwidget.html#maximumSize-prop or one of its relatives.

  • Thanks for the quick reply.

    When I use setMaximumSize(), the plots stay at a fixed size when I stretch the window (and they react as if they weren't constrained by proportions when I use only SetMinimumSize).

  • Moderators

    Ah. I misunderstood what you were wanting, I think. Check out "QWidget::heightForWidth()":http://doc.qt.nokia.com/latest/qwidget.html#heightForWidth and see if reimplementing that handles your situation.

  • I've tried that but for some reason, the plots refuse to resize. Everything else resizes proportionally, but the plots stay fixed or unconstrained.

    Thanks for the suggestion though. Maybe I'll look into it some more again.

  • Moderators

    Hmm. I don't know. Maybe it is a Qwt issue then.

  • Moderators

    A QwtPlot should behave like any other QWidget in a QLayout. Do you use an ui file with Qt Designer or only code?
    Can you show us one of them?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.