PDA

View Full Version : multi plots



21did21
20th May 2011, 03:44
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...

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


#include <QApplication>
#include "MyMainWindow.h"
#include <QGridLayout>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyMainWindow fenetre;
fenetre.setWindowFlags(Qt::Window);

QGridLayout *MyGridLayout = new QGridLayout;
MyGridLayout->addWidget(fenetre.get_WindowNumber1(),0,0,3,3);
MyGridLayout->addWidget(fenetre.get_WindowNumber2(),0,3,3,3);
MyGridLayout->addWidget(fenetre.get_WindowNumber3(),0,6,3,3);
MyGridLayout->addWidget(fenetre.get_WindowNumber4(),3,0,3,3);
MyGridLayout->addWidget(fenetre.get_WindowNumber5(),3,3,3,3);
MyGridLayout->addWidget(fenetre.get_WindowNumber6(),3,6,3,3);
MyGridLayout->addWidget(fenetre.get_BUTTONRun(),0,8);
MyGridLayout->addWidget(fenetre.get_BUTTONQuit(),0,9);
MyGridLayout->addWidget(fenetre.get_BUTTONAbout(),1,8);
MyGridLayout->addWidget(fenetre.get_BUTTONContact(),1,9);
fenetre.setLayout(MyGridLayout);
fenetre.show();
return app.exec();
}

MyMainWindow.h

#ifndef MYMAINWINDOW_H
#define MYMAINWINDOW_H

#include <QApplication>
#include <QWidget>
#include <QPushButton>
#include <QMessageBox>
#include <qwt_plot.h>

class MyMainWindow : public QWidget
{
Q_OBJECT

public:
MyMainWindow();
~MyMainWindow();
QPushButton* get_BUTTONRun();
QPushButton* get_BUTTONQuit();
QPushButton* get_BUTTONAbout();
QPushButton* get_BUTTONContact();
QWidget* get_WindowNumber1();
QWidget* get_WindowNumber2();
QWidget* get_WindowNumber3();
QWidget* get_WindowNumber4();
QWidget* get_WindowNumber5();
QWidget* get_WindowNumber6();

private:
QPushButton *BUTTONRun;
QPushButton *BUTTONQuit;
QPushButton *BUTTONAbout;
QPushButton *BUTTONContact;
QWidget *WindowNumber1;
QWidget *WindowNumber2;
QWidget *WindowNumber3;
QWidget *WindowNumber4;
QWidget *WindowNumber5;
QWidget *WindowNumber6;
QwtPlot *myPlot1;
QwtPlot *myPlot2;
QwtPlot *myPlot3;
QwtPlot *myPlot4;
QwtPlot *myPlot5;
QwtPlot *myPlot6;
};
#endif // MYMAINWINDOW_H
MyMainWindow.cpp


#include "MyMainWindow.h"

MyMainWindow::MyMainWindow() : QWidget()
{
WindowNumber1= new QWidget(this);
WindowNumber2= new QWidget(this);
WindowNumber3= new QWidget(this);
WindowNumber4= new QWidget(this);
WindowNumber5= new QWidget(this);
WindowNumber6= new QWidget(this);
myPlot1=new QwtPlot(WindowNumber1);
myPlot2=new QwtPlot(WindowNumber2);
myPlot3=new QwtPlot(WindowNumber3);
myPlot4=new QwtPlot(WindowNumber4);
myPlot5=new QwtPlot(WindowNumber5);
myPlot6=new QwtPlot(WindowNumber6);

BUTTONRun = new QPushButton("RUN", this);
BUTTONQuit = new QPushButton("STOP", this);
BUTTONAbout = new QPushButton("About", this);
BUTTONContact = new QPushButton("Contact", this);

QObject::connect(BUTTONQuit, SIGNAL(clicked()), qApp, SLOT(quit()));
QObject::connect(BUTTONAbout, SIGNAL(clicked()), qApp, SLOT(aboutQt()));

}
MyMainWindow::~MyMainWindow()
{

}

QPushButton* MyMainWindow::get_BUTTONRun()
{
return BUTTONRun;
}

QPushButton* MyMainWindow::get_BUTTONQuit()
{
return BUTTONQuit;
}

QPushButton* MyMainWindow::get_BUTTONAbout()
{
return BUTTONAbout;
}

QPushButton* MyMainWindow::get_BUTTONContact()
{
return BUTTONContact;
}

QWidget* MyMainWindow::get_WindowNumber1()
{
return WindowNumber1;
}

QWidget* MyMainWindow::get_WindowNumber2()
{
return WindowNumber2;
}

QWidget* MyMainWindow::get_WindowNumber3()
{
return WindowNumber3;
}

QWidget* MyMainWindow::get_WindowNumber4()
{
return WindowNumber4;
}

QWidget* MyMainWindow::get_WindowNumber5()
{
return WindowNumber5;
}

QWidget* MyMainWindow::get_WindowNumber6()
{
return WindowNumber6;
}

Santosh Reddy
20th May 2011, 18:49
Try reworking on the column, row, row span, and column span when laying out the widgert, try using the numbers in this code


// Row 0, Column 0, 1, 2. All these are 3-Rows in height, and 1-Column is Width
MyGridLayout->addWidget(fenetre.get_WindowNumber1(),0,0,3,1);
MyGridLayout->addWidget(fenetre.get_WindowNumber2(),0,1,3,1);
MyGridLayout->addWidget(fenetre.get_WindowNumber3(),0,2,3,1);

// Row 3, Column 0, 1, 2. All these are 3-Rows in height, and 1-Column is Width
MyGridLayout->addWidget(fenetre.get_WindowNumber4(),3,0,3,1);
MyGridLayout->addWidget(fenetre.get_WindowNumber5(),3,1,3,1);
MyGridLayout->addWidget(fenetre.get_WindowNumber6(),3,2,3,1);

//Buttons
// Row 0, 1, 2, 3, Column 3. All these are 1-Row in height, and 1-Column is Width
MyGridLayout->addWidget(fenetre.get_BUTTONRun() ,0,3,1,1);
MyGridLayout->addWidget(fenetre.get_BUTTONQuit() ,1,3,1,1);
MyGridLayout->addWidget(fenetre.get_BUTTONAbout() ,2,3,1,1);
MyGridLayout->addWidget(fenetre.get_BUTTONContact(),3,3,1,1);

21did21
20th May 2011, 20:12
thank you a lot, i will try this.

see you

21did21
20th May 2011, 22:28
I have test yout code but it make problems...

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

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

Santosh Reddy
23rd May 2011, 20:55
I think you need to properly configure the min, max, and hint sizes for the widgets defined in QWT.

Uwe
23rd May 2011, 22:25
I think you need to properly configure the min, max, and hint sizes for the widgets defined in QWT.
No much simpler - all plot widgets are uncontrolled by a layout ( only the parent widgets of the plots are ).

QLayout problems are completely unrelated to Qwt ( it doesn't matter if you want to arrange QwtPlots or any other Qt widgets ) and insisting on posting in the wrong group will only result in getting no answer.

Again: the newbie section is made for question like this one !

Uwe

Troudhyl
23rd May 2011, 23:40
And about this one (http://www.qtcentre.org/threads/41580-x-bottom-scale-div-linked-to-pixels-even-if-resizing) ?

Santosh Reddy
24th May 2011, 01:11
I agree with Uwe