![]() |
2010-07-16
, 09:51
|
|
Posts: 2,154 |
Thanked: 2,186 times |
Joined on Dec 2009
@ Hellsinki, Finland
|
#12
|
Put the connect inside MainWindow's constructor (function named MainWindow::MainWindow() )in mainwindow.cpp and the function hello also in same file but not inside anything. You'll probably also need to put some includes in the beginning of the file:
Code:#include <QProcess> #include <QStringList>
#include <QProcess> #include <QStringList> #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(hello())); delete ui; } void MainWindow::hello() { QStringList arguments; arguments << "Enable custom transitions" << "Droid Sans" << "Black"; QProcess::execute("/path/to/my/script/script.sh", arguments); }
![]() |
2010-07-16
, 09:56
|
|
Posts: 1,296 |
Thanked: 1,773 times |
Joined on Aug 2009
@ Budapest, Hungary
|
#13
|
Thanks for this, but how do I put the input from those select boxes as arguments?
ui->myComboBox->doStuff();
The Following User Says Thank You to Venemo For This Useful Post: | ||
![]() |
2010-07-16
, 09:57
|
|
Posts: 1,296 |
Thanked: 1,773 times |
Joined on Aug 2009
@ Budapest, Hungary
|
#14
|
You'll probably also need to put some includes in the beginning of the file:
Code:#include <QProcess> #include <QStringList>
#include <QtCore> #include <QtGui>
The Following User Says Thank You to Venemo For This Useful Post: | ||
![]() |
2010-07-16
, 10:00
|
Posts: 353 |
Thanked: 263 times |
Joined on Dec 2009
@ Finland
|
#15
|
After doing these I get build issue described as:
no 'void MainWindow::hello()' member function declared in class 'MainWindow'
class MainWindow : ..... { // .... public slots: void hello(); // .... };
![]() |
2010-07-16
, 10:17
|
|
Posts: 2,154 |
Thanked: 2,186 times |
Joined on Dec 2009
@ Hellsinki, Finland
|
#16
|
You can reach the widgets on the .ui with the ui variable in your cpp code.
Eg.
About what do do with a combo box, here is some doc:Code:ui->myComboBox->doStuff();
http://doc.qt.nokia.com/4.6/qcombobox.html
Qt is _very well_ documented, you should be able to find anything you want to know about it!
![]() |
2010-07-16
, 10:23
|
|
Posts: 1,296 |
Thanked: 1,773 times |
Joined on Aug 2009
@ Budapest, Hungary
|
#17
|
EDIT: And your connect seems to be now in wrong place, it's in the destructor (MainWindow::~MainWindow()) though it should be in constructor (MainWindow::MainWindow())
![]() |
2010-07-16
, 10:28
|
|
Posts: 1,296 |
Thanked: 1,773 times |
Joined on Aug 2009
@ Budapest, Hungary
|
#18
|
Okay, I got the apply -button to launch the script. Still haven't figured out how to get the text string from drop down menus to be put as variables.
After that it should be pretty much done.
I found this, but don't know what to do with it
http://doc.qt.nokia.com/4.6/qcombobox.html#activated-2
QString myString;
myString = "mydefaultstuff"
myString = text;
![]() |
2010-07-16
, 10:28
|
|
Posts: 2,154 |
Thanked: 2,186 times |
Joined on Dec 2009
@ Hellsinki, Finland
|
#19
|
Yeah.
About the connect() calls - it is a good practice to put them into the constructor. However, for items in the .ui, it is best to create the slots with the designer and let it do this for you.
(That way, the connect() is taken care of by the designer and you don't have to call it yourself.)
![]() |
2010-07-16
, 10:29
|
Posts: 180 |
Thanked: 76 times |
Joined on May 2010
|
#20
|
Okay, I got the apply -button to launch the script. Still haven't figured out how to get the text string from drop down menus to be put as variables.
After that it should be pretty much done.
I found this, but don't know what to do with it
http://doc.qt.nokia.com/4.6/qcombobox.html#activated-2
ui->myComboBox->currentText(); //This property holds the text of the current item.
connect(ui->myComboBox, SIGNAL(currentIndexChanged(QString), this, SLOT(comboBoxCurrentIndexChanged(QString));
void MainWindow::comboBoxCurrentIndexChanged(const QString &text) { //Do something }
My Maemo5 projects:
mSpede - Speed testing game | Them Bloody Ducks - 2D duck hunting game | Maetronome - A simple metronome app | CuteMPC - MPD client