Results 1 to 7 of 7

Thread: QwtPlot resize

  1. #1
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot resize

    So far, I subclassed QwtPlot, I rewrote the sizeHint() method and I specified size policy :

    // Overload sizeHint
    QSize PlotDistanceReccurence::sizeHint()
    {
    return QSize(-1, -1);
    }

    // In constructor...
    setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    which allowed to reduce a little further the size of the QwtPlot but I still see a limit. Where can it comes from ?
    Last edited by moijhd; 25th February 2013 at 10:35.

  2. #2
    Join Date
    Nov 2012
    Posts
    34
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 2 Times in 2 Posts

    Default Re: QwtPlot resize

    Try one of these:
    Qt Code:
    1. void QWidget::setMinimumSize(const QSize &);
    2. void QWidget::setMinimumSize(int minw, int minh);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot resize

    setMinimumSize(0, 0); does not change anything to my issue.

    My main concern is that I don't have control on how small (or not small here) can a plot be.
    Last edited by moijhd; 25th February 2013 at 12:28.

  4. #4
    Join Date
    Nov 2012
    Posts
    34
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 2 Times in 2 Posts

    Default Re: QwtPlot resize

    What did you call setMinimumSize() on or from, the plot?

    Is your plot in a QLayout?

  5. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: QwtPlot resize

    Quote Originally Posted by moijhd View Post
    My main concern is that I don't have control on how small (or not small here) can a plot be.
    First of all you should have a look at QWidget::sizePolicy() and QWidget::sizeHint(), QWidget::minimumSizeHint() to understand the very basics about how Qt layouts work.

    Concerning layouts there is nothing special about QwtPlot beside that it implements size hints depending on the place that is needed for the tick labels. You can set a size policy that ignores the size hint or overload and return a different size hint if your applications knows something better.

    Uwe

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

    embeddedmz (29th July 2019)

  7. #6
    Join Date
    Feb 2013
    Posts
    38
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot resize

    @Seamus

    I have a QWidget. I set a QGridLayout on it. Then I add the QwtPlot in the QGridLayout. And I set on the QwtPlot a size policy and overloaded the sizeHint method (cf previous posts). And I also set setMinimumSize() on the plot.

    If I understood where you are going, I should set those parameters to the container of my QwtPlot which should force the size of the plot ?

    @uwe

    I worked with all those functions. I might be still missing something. Though I don't know what so far. I think you are also pointing out the fact that I should set the parameters to the container ? Regarding the tick labels, I effectively noticed that some "int niceDist = 40" exists on the QwtPlot methods.

    I suppose that a QwtPlot or a QToolButton should work similarly but so far it does not (if I don't modify any parameter). It also seems that the behavior of QwtPlot is different on Linux and Window (I am currently working on Window but I had it tested on Linux).

  8. #7
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,326
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanked 880 Times in 828 Posts

    Default Re: QwtPlot resize

    Quote Originally Posted by moijhd View Post
    I worked with all those functions. I might be still missing something. Though I don't know what so far. I think you are also pointing out the fact that I should set the parameters to the container ?
    No I wanted to say, that the answer to all of your questions means understanding the Qt layout system.

    Uwe

Similar Threads

  1. Replies: 3
    Last Post: 11th December 2011, 10:09
  2. qwtplot wont resize
    By marc2050 in forum Qwt
    Replies: 1
    Last Post: 31st July 2011, 13:08
  3. Replies: 1
    Last Post: 9th May 2011, 20:45
  4. Replies: 6
    Last Post: 14th May 2009, 12:02
  5. Replies: 2
    Last Post: 22nd January 2008, 16:10

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
  •  
Qt is a trademark of The Qt Company.