21did21
27th May 2011, 00:26
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
#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;
}
i have test this:
// 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);
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...
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
#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;
}
i have test this:
// 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);
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...