Results 1 to 4 of 4

Thread: How do I get a plot working using Qt Creator and the Design Tab?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Posts
    3
    Thanks
    1

    Default How do I get a plot working using Qt Creator and the Design Tab?

    I've spent a few hours looking, but I've found nothing.

    I already know how to do all the basic stuff via coding in c++, but I'm trying to figure out how to do this using the Qt Creator Design tab.

    Steps I do so far:
    1) Open my project from Qt Creator
    2) Open my mainwindow.ui file which takes me to the design tab
    3) drag and drop a Qwt Plot widget onto my form
    4) ?


    As I said, I've already got my program working by using the following mainwindow code (that does not use a ui file), but I want to figure out how to do this from the Qt Creator Designer tab.

    Current working non-ui mainwindow.cpp code:

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "plot.h"
    3. #include <qwt_scale_engine.h>
    4. #include <qlabel.h>
    5. #include <qlayout.h>
    6.  
    7. MainWindow::MainWindow( QWidget *parent ):
    8. QWidget( parent )
    9. {
    10. const double intervalLength = 10.0; // seconds
    11.  
    12. d_plot = new Plot( this );
    13. d_plot->setIntervalLength( intervalLength );
    14.  
    15.  
    16. QHBoxLayout *layout = new QHBoxLayout( this );
    17. layout->addWidget( d_plot, 10 );
    18. }
    19.  
    20. void MainWindow::start()
    21. {
    22. d_plot->start();
    23. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    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 do I get a plot working using Qt Creator and the Design Tab?

    In the designer add a plain widget and promote it to Plot, Right click on widget and then prommote, here give the Plot class details.

    Then your code should look like this
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "plot.h"
    3. #include <qwt_scale_engine.h>
    4. #include <qlabel.h>
    5. #include <qlayout.h>
    6.  
    7. #include "ui_plot.h"
    8.  
    9. MainWindow::MainWindow( QWidget *parent ):
    10. QWidget( parent ),
    11. ui(new Ui::Plot())
    12. {
    13. const double intervalLength = 10.0; // seconds
    14.  
    15. setupUi(this);
    16. ui->plot->setIntervalLength( intervalLength );
    17. }
    18.  
    19. void MainWindow::start()
    20. {
    21. ui->plot->start();
    22. }
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    CodingGnome (23rd August 2013)

Similar Threads

  1. Replies: 4
    Last Post: 4th June 2011, 10:38
  2. Replies: 0
    Last Post: 28th October 2010, 13:24
  3. computer crash with Qt Design/ Qt Creator Designer
    By OverTheOCean in forum Qt Tools
    Replies: 1
    Last Post: 26th September 2009, 16:23
  4. Sticks on plot not working
    By giusepped in forum Qwt
    Replies: 3
    Last Post: 11th February 2009, 09:55
  5. Sticks on plot not working
    By giusepped in forum Qwt
    Replies: 0
    Last Post: 10th February 2009, 07:19

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.