Results 1 to 10 of 10

Thread: QwtPlotRescaler extra space

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Join Date
    Dec 2017
    Posts
    11
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QwtPlotRescaler extra space

    Quote Originally Posted by Uwe View Post

    Or even better: try overload QwtPlot::updateLayout and put your code there. If this is possible you don't need to take care of when to call what.

    Uwe
    I have been trying to do this by creating a class that inherits from QwtPlot and by overriding the virtual function updateLayout. I think everythink would work fine if there would be a way of making the plot fill the whole widget! I mean, before having this derived class (plotclass.h), I would go to the QtDesigner, right click over the selected widget and choose the option "Promote to" and then "QwtPlot" and everything would be okay since the plot would fill the entire widget space.
    The code for my derived class is:
    Qt Code:
    1. #include "plotclass.h"
    2. #include "qwt_scale_widget.h"
    3.  
    4. plotClass::plotClass(QWidget *parent):
    5. QwtPlot(parent)
    6. {
    7. ;
    8. }
    9.  
    10. void plotClass::updateLayout()
    11. {
    12. int width_yRight;
    13. int height_xBottom;
    14. int width_yLeft;
    15. if(this->axisEnabled(QwtPlot::yRight))
    16. width_yRight = this->axisWidget(QwtPlot::yRight)->width();
    17. else
    18. width_yRight = 0;
    19. if(this->axisEnabled(QwtPlot::yLeft) && this->axisEnabled(QwtPlot::xBottom))
    20. {
    21. height_xBottom = this->axisWidget(QwtPlot::xBottom)->height();
    22. width_yLeft = this->axisWidget(QwtPlot::yLeft)->width();
    23. }
    24. else
    25. {
    26. height_xBottom = 0;
    27. width_yLeft = 0;
    28. }
    29. int h = this->height();
    30. int w = (h-height_xBottom) + (width_yLeft+width_yRight);
    31. this->resize(w,h);
    32. this->move((this->parentWidget()->width()-w)/2,(this->parentWidget()->height()-h)/2);
    33. }
    To copy to clipboard, switch view to plain text mode 

    and the code for the main window which creates an instance of it is:

    Qt Code:
    1. (...)
    2. ui->setupUi(this);
    3. myPlot = new plotClass(ui->widget);
    4. (...)
    To copy to clipboard, switch view to plain text mode 
    , in which widget is the widget I created on the qt designer to be the container of plotclass.

    gagagag.PNG
    This is basically what I am getting, isn't it possible to tell the qwtplot to fill the whole parent widget?

    Thank you!
    Last edited by airflow; 27th January 2018 at 15:43. Reason: add image

Similar Threads

  1. QwtPlotRescaler does not work
    By A1exander_Z in forum Qwt
    Replies: 2
    Last Post: 26th February 2016, 11:49
  2. Remove extra space around legend
    By adeas31 in forum Qwt
    Replies: 0
    Last Post: 17th November 2015, 13:21
  3. AutoScal affects QwtPlotRescaler
    By jesse_mark in forum Qwt
    Replies: 0
    Last Post: 28th November 2012, 15:00
  4. Make QwtPlotRescaler reflect data changes
    By hector1984 in forum Qwt
    Replies: 1
    Last Post: 26th August 2010, 10:06
  5. Replies: 3
    Last Post: 28th September 2007, 20:54

Tags for this Thread

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.