karthikkm1987
7th December 2011, 12:56
Hai I am able to compile the program.But The gui is not running the shell scripts.
here is the code.
modbusarm.pro:--
#-------------------------------------------------
#
# Project created by QtCreator 2011-12-05T10:21:56
#
#-------------------------------------------------
QT += core gui
TARGET = modbusarm
TEMPLATE = app
SOURCES += main.cpp
HEADERS += modbusarm.h ui_modbusarm.h
FORMS += modbusarm.ui
header files:-
modbusarm.h
#ifndef MODBUSARM_H
#define MODBUSARM_H
#include<QDialog>
#include<QtGui>
#include<QProcess>
#include<QMainWindow>
#include"ui_modbusarm.h"
#include<QByteArray>
//#include<Qt3Support/Q3Process>
class modbusarm:public QMainWindow,public Ui_modbusarm
{
Q_OBJECT
public:
QProcess* proc1;
QProcess* proc2;
modbusarm()
{
setupUi(this);
/* create QProcess object */
proc1= new QProcess();
QString stringproc1="/home/karthik/Desktop/hai ";
proc1->start(stringproc1);
/* show output */
// connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(readAllStandardOutput()) );
connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(rightMessage1()) );
// connect(proc1, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage1()) );
/*------------------------------------------------------------------------------------------*/
/* create QProcess object */
proc2= new QProcess();
QString stringproc2="/home/karthik/Desktop/hai";
proc2->start(stringproc2);
// connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(readAllStandardOutput()) );
/* show output */
connect(proc2, SIGNAL(readyReadStandardOutput()),this, SLOT(rightMessage2()) );
//connect(proc2, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage2()) );
}
void rightMessage1()
{
QByteArray data = proc1->readAllStandardOutput();
//arm1->setText(QString data);
QString text = arm1->text() + QString(data);
arm1->setText(text);
}
void rightMessage2()
{
QByteArray data1 = proc2->readAllStandardOutput();
QString text1 = arm2->text() + QString(data1);
arm2->setText(text1);
}
// ~modbusarm();
private:
//Ui::modbusarm *ui;
};
#endif // MODBUSARM_H
modbusarm.cppsource file
#include "modbusarm.h"
#include "ui_modbusarm.h"
modbusarm::modbusarm(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::modbusarm)
{
ui->setupUi(this);
}
modbusarm::~modbusarm()
{
delete ui;
}
main.cpp
#include <QApplication>
#include "modbusarm.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
modbusarm* w=new modbusarm();
w->show();
return a.exec();
}
the shell scripts are
#!/bin/bash
c=0
while [ 1 ]
do
((c++))
echo " hai $c times "
sleep 1https://mail.google.com/mail/images/cleardot.gif
done
Please Help Me.
The output of shell scripts should be continuously outputted at Line edit of GU I have attached the UI file also.71577158
here is the code.
modbusarm.pro:--
#-------------------------------------------------
#
# Project created by QtCreator 2011-12-05T10:21:56
#
#-------------------------------------------------
QT += core gui
TARGET = modbusarm
TEMPLATE = app
SOURCES += main.cpp
HEADERS += modbusarm.h ui_modbusarm.h
FORMS += modbusarm.ui
header files:-
modbusarm.h
#ifndef MODBUSARM_H
#define MODBUSARM_H
#include<QDialog>
#include<QtGui>
#include<QProcess>
#include<QMainWindow>
#include"ui_modbusarm.h"
#include<QByteArray>
//#include<Qt3Support/Q3Process>
class modbusarm:public QMainWindow,public Ui_modbusarm
{
Q_OBJECT
public:
QProcess* proc1;
QProcess* proc2;
modbusarm()
{
setupUi(this);
/* create QProcess object */
proc1= new QProcess();
QString stringproc1="/home/karthik/Desktop/hai ";
proc1->start(stringproc1);
/* show output */
// connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(readAllStandardOutput()) );
connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(rightMessage1()) );
// connect(proc1, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage1()) );
/*------------------------------------------------------------------------------------------*/
/* create QProcess object */
proc2= new QProcess();
QString stringproc2="/home/karthik/Desktop/hai";
proc2->start(stringproc2);
// connect(proc1, SIGNAL(readyReadStandardOutput()),this, SLOT(readAllStandardOutput()) );
/* show output */
connect(proc2, SIGNAL(readyReadStandardOutput()),this, SLOT(rightMessage2()) );
//connect(proc2, SIGNAL(readyReadStandardError()), this, SLOT(wrongMessage2()) );
}
void rightMessage1()
{
QByteArray data = proc1->readAllStandardOutput();
//arm1->setText(QString data);
QString text = arm1->text() + QString(data);
arm1->setText(text);
}
void rightMessage2()
{
QByteArray data1 = proc2->readAllStandardOutput();
QString text1 = arm2->text() + QString(data1);
arm2->setText(text1);
}
// ~modbusarm();
private:
//Ui::modbusarm *ui;
};
#endif // MODBUSARM_H
modbusarm.cppsource file
#include "modbusarm.h"
#include "ui_modbusarm.h"
modbusarm::modbusarm(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::modbusarm)
{
ui->setupUi(this);
}
modbusarm::~modbusarm()
{
delete ui;
}
main.cpp
#include <QApplication>
#include "modbusarm.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
modbusarm* w=new modbusarm();
w->show();
return a.exec();
}
the shell scripts are
#!/bin/bash
c=0
while [ 1 ]
do
((c++))
echo " hai $c times "
sleep 1https://mail.google.com/mail/images/cleardot.gif
done
Please Help Me.
The output of shell scripts should be continuously outputted at Line edit of GU I have attached the UI file also.71577158