Results 1 to 6 of 6

Thread: Shell command from Qt 4.5.2 by QProcess

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Posts
    39
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11
    Thanks
    3

    Arrow Shell command from Qt 4.5.2 by QProcess

    Hi Everyone.........
    Plz can you send me small code just it has to send some command to CLI. I'm working in ARM i.MX31 ARM board. I need to interact CLI by using Qt 4.5.2. So i need just a simple code to execute on CLI (command Line Interface). For example i need to see all list of folders or dir on Root file system(rfs). Plz can you check it out, give solution how to do it. If i click on button it has to display list of folders and dir on CLI first.
    Im writing my complete code of my project here and im attaching .ui file as in zip format. Plz check it out, assit me to pass commands for CLI. plz quote an small example also.overall if i click on button on GUI. it has to send command "ls -l" to CLI, Atleast i need to list of folders and directories on CLI after cancelling GUI, later on i can work it out to bring uo data on CLI to textedit box.. Thanking you in advance see all my attached and written code below.

    Asking directly my AIM is to just click on button, if i cancel GUI. atleast i want see "ls -l" cmd on terminal and it should have list all the folders and directories.


    QPROCESS.PRO
    ================================================== ============================================
    #-------------------------------------------------
    #
    # Project created by QtCreator 2009-12-10T15:21:05
    #
    #-------------------------------------------------

    TARGET = Qprocess
    TEMPLATE = app


    SOURCES += main.cpp\
    mainwindow.cpp

    HEADERS += mainwindow.h

    FORMS += mainwindow.ui
    ================================================== ================================================== ==========

    main.cpp
    ================================================== ================================================== ==========
    #include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
    }
    ================================================== ================================================== ===========
    mainwindow.cpp
    ================================================== ================================================== ===========
    #include "mainwindow.h"
    #include "ui_mainwindow.h"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
    {
    ui->setupUi(this);

    pushbutton =new QPushButton;
    pushbutton=ui->pushButton;

    connect(pushbutton,SIGNAL(clicked()),this,SLOT(but tonclicked()));





    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::buttonclicked()
    {
    pushbutton->setText("VINAY");
    proc=new QProcess(this);
    proc->start("VKB -qws");//Actually i want to give commands like ls -l or cd .. which should be passed to CLI and act on that. but im not finding options in proc-> . Plz can you send me a small code to interact with CLI.

    }
    ================================================== ================================================== ===========
    mainwindow.h
    ================================================== ================================================== ===========
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QtGui/QMainWindow>
    #include <QProcess>
    #include <QPushButton>
    #include <QTextEdit>
    class QProcess;

    namespace Ui
    {
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();

    private:
    Ui::MainWindow *ui;
    private:
    QProcess *proc;
    QPushButton *pushbutton;
    private slots:
    void buttonclicked();
    };

    #endif // MAINWINDOW_H
    ================================================== ===================================
    Attached Files Attached Files

Similar Threads

  1. QProcess & linux shell characters
    By Ti_Thom in forum Qt Programming
    Replies: 4
    Last Post: 21st December 2009, 10:01
  2. qprocess and shell
    By GuL in forum Qt Programming
    Replies: 1
    Last Post: 12th February 2009, 05:47
  3. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.