码迷,mamicode.com
首页 > Windows程序 > 详细

QT编程实现windows的运行windows+R

时间:2014-09-09 20:09:39      阅读:287      评论:0      收藏:0      [点我收藏+]

标签:qt

使用在windows下面的windows+R实现的运行程序

widget.h

#ifndef WIDGET_H

#define WIDGET_H
#include <QWidget>
#include <QProcess>
namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT
    
public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();
    
private slots:
    void on_submitButton_clicked();


private:
    Ui::Widget *ui;
};

#endif // WIDGET_H


main.cpp

#include <QtGui/QApplication>
#include "widget.h"
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();
    
    return a.exec();
}

#include "widget.h"
#include "ui_widget.h"
#include <QWidget>
#include <QProcess>
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setMaximumSize(391,171);
    this->setMinimumSize(391,171);
    QObject::connect(ui->cmdLineEdit,SIGNAL(returnPressed()),this,SLOT(on_submitButton_clicked()));
}
Widget::~Widget()
{
    delete ui;
}
void Widget::on_submitButton_clicked()
{
    QProcess *process = new QProcess;
    QString startProgram=ui->cmdLineEdit->text();
    process->start(startProgram.trimmed());
    ui->cmdLineEdit->clear();
    this->close();
}

widget.cpp

QT编程实现windows的运行windows+R

标签:qt

原文地址:http://blog.csdn.net/u011046042/article/details/39160007

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!