Results 1 to 8 of 8

Thread: how i can increase the size of my plots and have a good organisation of this widget ?

  1. #1
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default how i can increase the size of my plots and have a good organisation of this widget ?

    Hello world,

    i use QtCreator and Qwt, i try to plot in real time 6 curve but i not a master in programmation and it's very difficult for me...
    Qwt use widget which have name "plot", it work like all the other widget but i can't increase their size and i don't know why...

    can you help me to:
    1°) place my curve correctly
    2°) with the good size

    i do a project to place 6curve and 4button on a windows, the result is nice (http://imageshack.us/photo/my-images/851/myplots.jpg/) but i want to increase the size of my plot and have a good arrangement
    ==> the plots have to take the total windows (except button emplacement)

    How i have to modify this programm to have bigger plots with a good arrangement ?
    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "MyMainWindow.h"
    3. #include <QGridLayout>
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. MyMainWindow fenetre;
    8. fenetre.setWindowFlags(Qt::Window);
    9.  
    10. QGridLayout *MyGridLayout = new QGridLayout;
    11. MyGridLayout->addWidget(fenetre.get_WindowNumber1(),0,0,3,3);
    12. MyGridLayout->addWidget(fenetre.get_WindowNumber2(),0,3,3,3);
    13. MyGridLayout->addWidget(fenetre.get_WindowNumber3(),0,6,3,3);
    14. MyGridLayout->addWidget(fenetre.get_WindowNumber4(),3,0,3,3);
    15. MyGridLayout->addWidget(fenetre.get_WindowNumber5(),3,3,3,3);
    16. MyGridLayout->addWidget(fenetre.get_WindowNumber6(),3,6,3,3);
    17. MyGridLayout->addWidget(fenetre.get_BUTTONRun(),0,8);
    18. MyGridLayout->addWidget(fenetre.get_BUTTONQuit(),0,9);
    19. MyGridLayout->addWidget(fenetre.get_BUTTONAbout(),1,8);
    20. MyGridLayout->addWidget(fenetre.get_BUTTONContact(),1,9);
    21. fenetre.setLayout(MyGridLayout);
    22. fenetre.show();
    23. return app.exec();
    24. }
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.h
    Qt Code:
    1. #ifndef MYMAINWINDOW_H
    2. #define MYMAINWINDOW_H
    3.  
    4. #include <QApplication>
    5. #include <QWidget>
    6. #include <QPushButton>
    7. #include <QMessageBox>
    8. #include <qwt_plot.h>
    9.  
    10. class MyMainWindow : public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. MyMainWindow();
    16. ~MyMainWindow();
    17. QPushButton* get_BUTTONRun();
    18. QPushButton* get_BUTTONQuit();
    19. QPushButton* get_BUTTONAbout();
    20. QPushButton* get_BUTTONContact();
    21. QWidget* get_WindowNumber1();
    22. QWidget* get_WindowNumber2();
    23. QWidget* get_WindowNumber3();
    24. QWidget* get_WindowNumber4();
    25. QWidget* get_WindowNumber5();
    26. QWidget* get_WindowNumber6();
    27.  
    28. private:
    29. QPushButton *BUTTONRun;
    30. QPushButton *BUTTONQuit;
    31. QPushButton *BUTTONAbout;
    32. QPushButton *BUTTONContact;
    33. QWidget *WindowNumber1;
    34. QWidget *WindowNumber2;
    35. QWidget *WindowNumber3;
    36. QWidget *WindowNumber4;
    37. QWidget *WindowNumber5;
    38. QWidget *WindowNumber6;
    39. QwtPlot *myPlot1;
    40. QwtPlot *myPlot2;
    41. QwtPlot *myPlot3;
    42. QwtPlot *myPlot4;
    43. QwtPlot *myPlot5;
    44. QwtPlot *myPlot6;
    45. };
    46. #endif // MYMAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.cpp
    Qt Code:
    1. #include "MyMainWindow.h"
    2.  
    3. MyMainWindow::MyMainWindow() : QWidget()
    4. {
    5. WindowNumber1= new QWidget(this);
    6. WindowNumber2= new QWidget(this);
    7. WindowNumber3= new QWidget(this);
    8. WindowNumber4= new QWidget(this);
    9. WindowNumber5= new QWidget(this);
    10. WindowNumber6= new QWidget(this);
    11. myPlot1=new QwtPlot(WindowNumber1);
    12. myPlot2=new QwtPlot(WindowNumber2);
    13. myPlot3=new QwtPlot(WindowNumber3);
    14. myPlot4=new QwtPlot(WindowNumber4);
    15. myPlot5=new QwtPlot(WindowNumber5);
    16. myPlot6=new QwtPlot(WindowNumber6);
    17.  
    18. BUTTONRun = new QPushButton("RUN", this);
    19. BUTTONQuit = new QPushButton("STOP", this);
    20. BUTTONAbout = new QPushButton("About", this);
    21. BUTTONContact = new QPushButton("Contact", this);
    22.  
    23. QObject::connect(BUTTONQuit, SIGNAL(clicked()), qApp, SLOT(quit()));
    24. QObject::connect(BUTTONAbout, SIGNAL(clicked()), qApp, SLOT(aboutQt()));
    25.  
    26. }
    27. MyMainWindow::~MyMainWindow()
    28. {
    29.  
    30. }
    31.  
    32. QPushButton* MyMainWindow::get_BUTTONRun()
    33. {
    34. return BUTTONRun;
    35. }
    36.  
    37. QPushButton* MyMainWindow::get_BUTTONQuit()
    38. {
    39. return BUTTONQuit;
    40. }
    41.  
    42. QPushButton* MyMainWindow::get_BUTTONAbout()
    43. {
    44. return BUTTONAbout;
    45. }
    46.  
    47. QPushButton* MyMainWindow::get_BUTTONContact()
    48. {
    49. return BUTTONContact;
    50. }
    51.  
    52. QWidget* MyMainWindow::get_WindowNumber1()
    53. {
    54. return WindowNumber1;
    55. }
    56.  
    57. QWidget* MyMainWindow::get_WindowNumber2()
    58. {
    59. return WindowNumber2;
    60. }
    61.  
    62. QWidget* MyMainWindow::get_WindowNumber3()
    63. {
    64. return WindowNumber3;
    65. }
    66.  
    67. QWidget* MyMainWindow::get_WindowNumber4()
    68. {
    69. return WindowNumber4;
    70. }
    71.  
    72. QWidget* MyMainWindow::get_WindowNumber5()
    73. {
    74. return WindowNumber5;
    75. }
    76.  
    77. QWidget* MyMainWindow::get_WindowNumber6()
    78. {
    79. return WindowNumber6;
    80. }
    To copy to clipboard, switch view to plain text mode 


    i have test this:
    Qt Code:
    1. // Row 0, Column 0, 1, 2. All these are 3-Rows in height, and 1-Column is Width
    2. MyGridLayout->addWidget(fenetre.get_WindowNumber1(),0,0,3,1);
    3. MyGridLayout->addWidget(fenetre.get_WindowNumber2(),0,1,3,1);
    4. MyGridLayout->addWidget(fenetre.get_WindowNumber3(),0,2,3,1);
    5.  
    6. // Row 3, Column 0, 1, 2. All these are 3-Rows in height, and 1-Column is Width
    7. MyGridLayout->addWidget(fenetre.get_WindowNumber4(),3,0,3,1);
    8. MyGridLayout->addWidget(fenetre.get_WindowNumber5(),3,1,3,1);
    9. MyGridLayout->addWidget(fenetre.get_WindowNumber6(),3,2,3,1);
    10.  
    11. //Buttons
    12. // Row 0, 1, 2, 3, Column 3. All these are 1-Row in height, and 1-Column is Width
    13. MyGridLayout->addWidget(fenetre.get_BUTTONRun() ,0,3,1,1);
    14. MyGridLayout->addWidget(fenetre.get_BUTTONQuit() ,1,3,1,1);
    15. MyGridLayout->addWidget(fenetre.get_BUTTONAbout() ,2,3,1,1);
    16. MyGridLayout->addWidget(fenetre.get_BUTTONContact(),3,3,1,1);
    To copy to clipboard, switch view to plain text mode 

    but this is the result:

    http://imageshack.us/photo/my-images/829/myplots.jpg/

    i don't understand how i can make a correct ploting...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    Lines 8 to 21 of main.cpp should be in the MyMainWindow constructor. This should reduce the work and complexity.

    You create a QWidget as container for each QwtPlot but do not set a layout on the QWidget. The QwtPlot has the container widget as its parent, so sits in the space of the QWidget but is not resized by a layout to file the space. Either have no parent QWidget and add the QwtPlot directly to the layout, or add the QwtPlot to a layout and then set that layout on the parent QWidget.

  3. #3
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    Ok, I took a small liberty to modify your code hope you don't mine it. This would make all the plots expand to the window size, and also not allow the window to be smaller than a certain size. I checked its working on my machine.
    QwtLayout.jpg
    main.cpp
    Qt Code:
    1. #include <QApplication>
    2. #include "MyMainWindow.h"
    3. #include <QGridLayout>
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication app(argc, argv);
    7. MyMainWindow fenetre;
    8. fenetre.show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.h
    Qt Code:
    1. #ifndef MYMAINWINDOW_H
    2. #define MYMAINWINDOW_H
    3.  
    4. #include <QApplication>
    5. #include <QWidget>
    6. #include <QPushButton>
    7. #include <QMessageBox>
    8. #include <qwt_plot.h>
    9.  
    10. class MyMainWindow : public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit MyMainWindow(QWidget* parent = 0);
    16.  
    17. private:
    18. QPushButton *BUTTONRun;
    19. QPushButton *BUTTONQuit;
    20. QPushButton *BUTTONAbout;
    21. QPushButton *BUTTONContact;
    22.  
    23. QwtPlot *myPlot1;
    24. QwtPlot *myPlot2;
    25. QwtPlot *myPlot3;
    26. QwtPlot *myPlot4;
    27. QwtPlot *myPlot5;
    28. QwtPlot *myPlot6;
    29. };
    30. #endif // MYMAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    MyMainWindow.cpp
    Qt Code:
    1. #include "MyMainWindow.h"
    2. #include <QGridLayout>
    3. #include <QHBoxLayout>
    4.  
    5. MyMainWindow::MyMainWindow(QWidget* parent) : QWidget(parent)
    6. {
    7. QGridLayout* mainLayout = new QGridLayout();
    8. setLayout(mainLayout);
    9.  
    10. myPlot1 = new QwtPlot();
    11. myPlot2 = new QwtPlot();
    12. myPlot3 = new QwtPlot();
    13. myPlot4 = new QwtPlot();
    14. myPlot5 = new QwtPlot();
    15. myPlot6 = new QwtPlot();
    16.  
    17. myPlot1->setMinimumSize(200, 100);
    18. myPlot2->setMinimumSize(200, 100);
    19. myPlot3->setMinimumSize(200, 100);
    20. myPlot4->setMinimumSize(200, 100);
    21. myPlot5->setMinimumSize(200, 100);
    22. myPlot6->setMinimumSize(200, 100);
    23.  
    24. QWidget* buttonWidget = new QWidget();
    25. QGridLayout* buttonLayout = new QGridLayout();
    26.  
    27. BUTTONRun = new QPushButton("RUN");
    28. BUTTONQuit = new QPushButton("STOP");
    29. BUTTONAbout = new QPushButton("About");
    30. BUTTONContact = new QPushButton("Contact");
    31.  
    32. buttonLayout->addWidget(BUTTONRun ,0,0);
    33. buttonLayout->addWidget(BUTTONQuit ,0,1);
    34. buttonLayout->addWidget(BUTTONAbout ,1,0);
    35. buttonLayout->addWidget(BUTTONContact,1,1);
    36.  
    37. buttonWidget->setLayout(buttonLayout);
    38.  
    39. mainLayout->addWidget(myPlot1 ,0,0,1,1);
    40. mainLayout->addWidget(myPlot2 ,0,1,1,1);
    41. mainLayout->addWidget(myPlot3 ,0,2,1,1);
    42. mainLayout->addWidget(myPlot4 ,1,0,1,1);
    43. mainLayout->addWidget(myPlot5 ,1,1,1,1);
    44. mainLayout->addWidget(myPlot6 ,1,2,1,1);
    45. mainLayout->addWidget(buttonWidget ,0,3,1,1);
    46.  
    47. QObject::connect(BUTTONQuit, SIGNAL(clicked()), qApp, SLOT(quit()));
    48. QObject::connect(BUTTONAbout, SIGNAL(clicked()), qApp, SLOT(aboutQt()));
    49. }
    To copy to clipboard, switch view to plain text mode 

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

    21did21 (30th May 2011)

  5. #4
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    ok! it's very nice!!!!
    thanks a lot! i will try to understand your modifications.

    thank you a lot

  6. #5
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    thanks you it's very nice but i don't understand this:

    Qt Code:
    1. explicit MyMainWindow(QWidget* parent = 0);
    To copy to clipboard, switch view to plain text mode 

    and this:

    Qt Code:
    1. MyMainWindow::MyMainWindow(QWidget* parent) : QWidget(parent)
    To copy to clipboard, switch view to plain text mode 

    why you put this thing ?

  7. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    This is just to make it more maintainable, and this way it can be added to a parent. In your case as you have only one window (that is were you plot), you create main window as

    Qt Code:
    1. MyMainWindow fenetre;
    2. fenetre.show();
    To copy to clipboard, switch view to plain text mode 

    In futrue if want to have a new main window, and have the old main window as child, or even have multiple old main windows, then it is helpful

    something like this will used then
    Qt Code:
    1. MyNewMainWindow window;
    2.  
    3. MyMainWindow* childPlotWindow1(window);
    4. MyMainWindow* childPlotWindow2(window);
    5.  
    6. // You can multiple screens in case you need.
    7.  
    8. window.show();
    To copy to clipboard, switch view to plain text mode 

  8. The following user says thank you to Santosh Reddy for this useful post:

    21did21 (30th May 2011)

  9. #7
    Join Date
    May 2011
    Posts
    122
    Thanks
    34
    Platforms
    Windows

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    thank a lot !!!


    Added after 44 minutes:


    just one thing:

    => do you know how i can put logarithm abscisses?
    Last edited by 21did21; 30th May 2011 at 22:44.

  10. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: how i can increase the size of my plots and have a good organisation of this widg

    QwtPlot::setAxisScaleEngine() with a QwtLog10ScaleEngine. Have a look at the Bode plot example in the Qwt sources.

    There is also a Qwt sub-forum here

  11. The following user says thank you to ChrisW67 for this useful post:

    21did21 (31st May 2011)

Similar Threads

  1. QSlider: Increase handle size -> How ?
    By ArneBurghardt in forum Qt Programming
    Replies: 6
    Last Post: 11th August 2016, 20:58
  2. increase the size of my plot
    By 21did21 in forum Qwt
    Replies: 4
    Last Post: 29th May 2011, 11:03
  3. QSystemTrayIcon - increase icon size
    By FredB in forum Qt Programming
    Replies: 0
    Last Post: 30th March 2011, 22:18
  4. Increase legend icon size?
    By torrentss in forum Qwt
    Replies: 2
    Last Post: 1st September 2010, 12:26
  5. Font size increase in QtableWidget
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 19th November 2009, 14: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.