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

使用在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

上一篇:Windows MFC 全局模态 实现


下一篇:单晶进展:隆基发表LIR技术、天合推双面PERC组件