Qt中线程与进程中 QProcess进程类提供一个运行外在应用程序的方法,当运行一个进程需要为start()复制一个QStringList类型的参数。
QString program =
"./path";
QStringList arguments;
arguments<<"-style"<<"motif";
QProcess *myProcess = new QProcess(parent);
myProcess->start(program,arguments);
在QProcess中父类中有个readAll();的函数
QByteArray QIODevice::readAll ()
This is an overloaded function.
Reads all available data from the device, and returns it as a QByteArray.
This function has no way of reporting errors; returning an empty QByteArray()
can mean either that no data was currently available
for reading, or that an error occurred.
可以得到外部执行的程序的显示等一系列结果; (然后处理显示在自己指定的窗口)
利用这貌似可以把 程序放在插件上运行,就像前段时间流行的excel上的联网三国杀,得到自己聊天信息做成插件放在编程软件上,获取部分聊天信息,在编程软件上进行交互,上班期间偷着聊天,别人还以为你是在调试程序。
还可以载入其他软件, 自己做壳。 不知道原理的还以为这软件是你写的,待测试
软件的自动更新 URL (????)怎么实现?? URL类中??url.path
::浏览器只能打开一个系列的 网站 打开其他则显示不可以:这个在移动营业厅中,电信营业厅,以及。。。。很多地方都有使用,
我们设想可以利用
QWebView *webView; QLineEdit *lineEdit;
还是源代码吧.....
Widget::Widget(QWidget *parent) : QWidget(parent) { webView = new QWebView; lineEdit = new QLineEdit; layout = new QVBoxLayout; progressBar = new QProgressBar; layout->addWidget(lineEdit); layout->addWidget(webView); layout->addWidget(progressBar); progressBar->reset(); progressBar->setMaximum(100); setLayout(layout); webView->load(QUrl("http://www.baidu.com")); webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(slotLoadUrl()));//回车键的信号 connect(webView, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted()));//开始装载的信号 connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool)));//装载完成的信号 connect(webView, SIGNAL(loadProgress(int)), this, SLOT(slotLoadProgress(int)));// connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(slotUrlChanged(QUrl)));//URL 发生改变时,, connect(webView, SIGNAL(linkClicked(QUrl)), this, SLOT(slotLinkClicked(QUrl)));//点击链接时的信号 } Widget::~Widget() { } void Widget::slotLoadUrl() { webView->load(lineEdit->text());//我们对lineEdit->text()进行过滤操作,以达到只能访问以某个网站为主页的操作 } void Widget::slotLoadStarted() { progressBar->reset(); setWindowTitle("Load Started...."); } void Widget::slotLoadFinished(bool b) { b ? setWindowTitle("Load Finished (true)....") : setWindowTitle("Load Finished (false)...."); } void Widget::slotLoadProgress(int i) { //setWindowTitle("Process = " + QString::number(i) + "%"); progressBar->setValue(i); } void Widget::slotUrlChanged(QUrl url) { lineEdit->setText(url.toString()); } void Widget::slotLinkClicked(QUrl url) { lineEdit->setText(url.toString()); webView->load(url);//我们对url.toString()进行过滤操作,以达到只能访问以某个网站为主页的操作 }