#include <QtGui>
#include "promo.h"
{
setupUi(this); // this sets up GUI
// signals/slots mechanism in action
connect( pushButton_browse, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect( pushButton_run, SIGNAL( clicked() ), this, SLOT( run() ) );
connect( pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) );
}
void myQtApp::getPath() //browse button
{
this,
"Choose a file to open",
lineEdit->setText( path );
}
void myQtApp::run() //to run process
{
int value1;
promo.start("a.exe"); //my c++ compiled executable
promo.waitForStarted();
if(radioButton->isChecked()) //writing radio button values
promo.write("1\n");
if(radioButton_2->isChecked())
promo.write("2\n");
if(radioButton_3->isChecked())
promo.write("3\n");
if(radioButton_4->isChecked())
promo.write("4\n");
QString num
= QVariant(spinBox1
->value
()).
toString()+"\n";
//spin box value to string called num promo.write(num.toAscii().data()); //writing to QBytearrya ie convert from string to array
promo.write(path.toAscii().data());
promo.closeWriteChannel(); //closing write channel
promo.waitForFinished();
}
void myQtApp::about() //about button
{
"is running\n"
);
}
#include <QtGui>
#include "promo.h"
myQtApp::myQtApp(QWidget *parent)
{
setupUi(this); // this sets up GUI
// signals/slots mechanism in action
connect( pushButton_browse, SIGNAL( clicked() ), this, SLOT( getPath() ) );
connect( pushButton_run, SIGNAL( clicked() ), this, SLOT( run() ) );
connect( pushButton_about, SIGNAL( clicked() ), this, SLOT( about() ) );
}
QString path;
void myQtApp::getPath() //browse button
{
path = QFileDialog::getOpenFileName(
this,
"Choose a file to open",
QString::null,
QString::null);
lineEdit->setText( path );
}
void myQtApp::run() //to run process
{
int value1;
QString str;
QString combo;
QProcess promo;
promo.start("a.exe"); //my c++ compiled executable
promo.waitForStarted();
if(radioButton->isChecked()) //writing radio button values
promo.write("1\n");
if(radioButton_2->isChecked())
promo.write("2\n");
if(radioButton_3->isChecked())
promo.write("3\n");
if(radioButton_4->isChecked())
promo.write("4\n");
QString num = QVariant(spinBox1->value()).toString()+"\n"; //spin box value to string called num
promo.write(num.toAscii().data()); //writing to QBytearrya ie convert from string to array
promo.write(path.toAscii().data());
promo.closeWriteChannel(); //closing write channel
promo.waitForFinished();
}
void myQtApp::about() //about button
{
QMessageBox::about(this,"About Promotif",
"is running\n"
);
}
To copy to clipboard, switch view to plain text mode
Thanks to
Bookmarks