use*_*359 3 qt webkit qt4 timer webview
我想创建一个程序,我将每行QPlainTextEdit发送到WebView,它将加载这些URL.我不需要检查URL,因为系统就是这样
http://someurl.com/ + each line of the QPlainTextEdit
Run Code Online (Sandbox Code Playgroud)
我有一些我不知道如何使用的想法:
所有这些都将通过等待另一个计时器每4小时完成.
首先,你需要的内容QPlainTextEdit.获取它们并使用新行分隔符将它们拆分,以获得QStrings每个代表一行的列表.
QString plainTextEditContents = ui->plainTextEdit->toPlainText()
QStringList lines = plainTextEditContents.split("\n");
Run Code Online (Sandbox Code Playgroud)
处理这些行的最简单方法是使用a QTimer并存储列表中当前索引的某个位置.
// Start the timer
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(processLine()));
timer->start(5000);
Run Code Online (Sandbox Code Playgroud)
现在,只要触发定时器,就会调用插槽.它只是得到当前的行,你可以随心所欲地做到这一点.
void processLine(){
// This is the current index in the string list. If we have reached the end
// then we stop the timer.
currentIndex ++;
if (currentIndex == lines.count())
{
timer.stop();
currentIndex = 0;
return;
}
QString currentLine = lines[currentIndex];
doSomethingWithTheLine(currentLine);
}
Run Code Online (Sandbox Code Playgroud)
同样地用4h计时器做同样的事情.
| 归档时间: |
|
| 查看次数: |
6664 次 |
| 最近记录: |