Results 1 to 2 of 2

Thread: use a QWT layout with QCustomPlot

  1. #1
    Join Date
    Mar 2016
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default use a QWT layout with QCustomPlot

    I am a little lost as to how to use a layout manager with QCP. I understand how to add rows and columns in QCP but I need to add a QListView to list come text to the right of my QCP graph. Since QCP can't add QWT elements (at least not to my knowledge) I need to use a QWT layout manager. I would like to add a QVBoxLayout to this code with. Thanks.

    (mainwindow.cpp)
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow){
    4. ui->setupUi(this);
    5. MainWindow::makePlot();
    6. }
    7.  
    8. ...............
    9.  
    10.  
    11.  
    12. void MainWindow::makePlot(QString stock){
    13. // set the title
    14. ui->customPlot->plotLayout()->insertRow(0);
    15. QCPPlotTitle *plotTitle = new QCPPlotTitle(ui->customPlot);
    16. plotTitle->setMargins(QMargins(0,0,0,0));
    17. plotTitle->setTextColor(QColor(255,255,255));
    18. plotTitle->setFont(QFont(QFont().family(), 12));
    19. plotTitle->setText("hello world");
    20. ui->customPlot->plotLayout()->addElement(0, 0, plotTitle);
    21. ui->customPlot->setBackground(QBrush(QColor(70,70,70)));
    22.  
    23. QCPFinancial *candlesticks = new QCPFinancial(ui->customPlot->xAxis, ui->customPlot->yAxis);
    24. ...............................................
    To copy to clipboard, switch view to plain text mode 
    (main.cpp)
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. MainWindow w;
    5. w.show();
    6.  
    7. return a.exec();
    8. }
    To copy to clipboard, switch view to plain text mode 
    (mainwindow.h)
    Qt Code:
    1. namespace Ui {
    2. class MainWindow;
    3. }
    4.  
    5.  
    6.  
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. explicit MainWindow(QWidget *parent = 0);
    13. ~MainWindow();
    14.  
    15. private slots:
    16. void makePlot(QString stock);
    17.  
    18. private:
    19. Ui::MainWindow *ui;
    20. protected:
    21.  
    22. };
    23.  
    24.  
    25.  
    26.  
    27. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: use a QWT layout with QCustomPlot

    I don't know that this has to do with QWT, but if you want a QListView side by side with the QCustomPlot widget, you add both to a QHBoxLayout.

    Cheers,
    _

Similar Threads

  1. Unable to setup Qcustomplot
    By HarshaSri in forum Newbie
    Replies: 1
    Last Post: 27th December 2015, 22:29
  2. Plotting charts with QCustomPlot
    By netinho.kernel in forum Qt Programming
    Replies: 1
    Last Post: 14th November 2014, 00:15
  3. QCustomplot
    By Harshavardhan in forum Newbie
    Replies: 1
    Last Post: 10th March 2014, 20:13
  4. Help with QCustomPlot
    By aashok91 in forum Qt Programming
    Replies: 0
    Last Post: 9th January 2013, 00:56
  5. QRubberband and QcustomPlot
    By OzQTNoob in forum Newbie
    Replies: 1
    Last Post: 16th October 2012, 03: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.