Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I run a command from a button press Qt - C++ probably
    primarykey
    data
    text
    <p>As I am trying to get a program finished, and I would like a graphical interface for it, I am trying to VERY QUICKLY rebuild a QT app provided as an example by QT Creator. Here are what I hope are the relevant bits:</p> <p><code>arrowpad.h</code>:</p> <pre><code>#ifndef ARROWPAD_H #define ARROWPAD_H #include &lt;QWidget&gt; QT_BEGIN_NAMESPACE class QPushButton; QT_END_NAMESPACE //! [0] class ArrowPad : public QWidget //! [0] //! [1] { //! [1] //! [2] Q_OBJECT //! [2] public: ArrowPad(QWidget *parent = 0); private: QPushButton *upButton; QPushButton *downButton; QPushButton *leftButton; QPushButton *rightButton; }; #endif </code></pre> <p><code>arrowpad.cpp</code>:</p> <pre><code>#include &lt;QtGui&gt; #include "arrowpad.h" ArrowPad::ArrowPad(QWidget *parent) : QWidget(parent) { //! [0] upButton = new QPushButton(tr("&amp;Up")); //! [0] //! [1] downButton = new QPushButton(tr("&amp;Down")); //! [1] //! [2] leftButton = new QPushButton(tr("&amp;Left")); //! [2] //! [3] rightButton = new QPushButton(tr("&amp;Right")); //! [3] QGridLayout *mainLayout = new QGridLayout; mainLayout-&gt;addWidget(upButton, 0, 1); mainLayout-&gt;addWidget(leftButton, 1, 0); mainLayout-&gt;addWidget(rightButton, 1, 2); mainLayout-&gt;addWidget(downButton, 2, 1); setLayout(mainLayout); } </code></pre> <p>How can I get it to run a command when I press a button? I have found <a href="https://stackoverflow.com/questions/3227767/how-to-run-a-system-command-in-qt">this</a>, but I don't know how to intergrate with the qpushbutton thing, otherwsie it just thinks it is a string of text... <strong>ANY COMMANDS MUST WORK IN LINUX - FEDORA 19, as that is what I am running it on.</strong></p> <p>Here is what the current result is - the button names I do not think are specified as <code>(tr("&amp;Up"));</code> in the above <code>.cpp</code> script by the way.</p> <p><img src="https://i.stack.imgur.com/3jJr9.png" alt="qt app"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload