Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. QwtPlot-resizeEvent Discarding Qualifiers
Forum Updated to NodeBB v4.3 + New Features

QwtPlot-resizeEvent Discarding Qualifiers

Scheduled Pinned Locked Moved 3rd Party Software
7 Posts 3 Posters 5.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    emihaumut
    wrote on last edited by
    #1

    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;
    e->size().setHeight(newW);
    
    QFrame::resizeEvent(e);
    updateLayout();
    

    }@

    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?

    Thanks.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      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.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        emihaumut
        wrote on last edited by
        #3

        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).

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          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.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • E Offline
            E Offline
            emihaumut
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

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

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • EddyE Offline
                EddyE Offline
                Eddy
                wrote on last edited by
                #7

                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?

                Qt Certified Specialist
                www.edalsolutions.be

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved