运行以下问题时出错:
@echo off
ping 8.8.4.4>c:\data.txt
FOR /F "tokens=3 delims= " %%A IN (c:\data.txt) DO SET SENTPACKETS=%%A
ECHO Packets sent: %SENTPACKETS%
FOR /F "tokens=7 delims= " %%A IN (c:\data.txt) DO SET RECEIVEDPACKETS=%%A
ECHO Packets received: %RECEIVEDPACKETS%
FOR /F "tokens=10 delims= " %%A IN (c:\data.txt) DO SET LOSTPACKETS=%%A
ECHO Packets lost: %LOSTPACKETS%
FOR /F "tokens=4 delims=,m " %%A IN (c:\data.txt) DO SET MINIMUMLATENCY=%%A
ECHO Minimum latency: %MINIMUMLATENCY%
FOR /F "tokens=9 delims=,m " %%A IN (c:\data.txt) DO SET MAXIMUMLATENCY=%%A
ECHO Maximum latency: %MAXIMUMLATENCY%
FOR /F "tokens=13 delims=,m " %%A IN (c:\data.txt) DO SET AVERAGELATENCY=%%A
ECHO Average latency: %AVERAGELATENCY%
pause
错误是:
该程序在#include <QMessageBox>
#include <QApplication>
int main() {
QApplication app();
QMessageBox msgBox(QMessageBox::Critical,
QObject::tr("text1"),
QObject::tr("text2"),
QMessageBox::Ok);
msgBox.exec();
return 0;
}
调用堆栈是:
编辑:即使我在名为QMessageBox msgBox(...);
的XTerm窗口中添加了QApplication
实例,我也会看到以下内容:
QWidget:必须在QWidget之前构建QApplication
答案 0 :(得分:1)
该行
QApplication app();
没有创建QApplication
对象 - 它实际上声明了一个不带参数的函数并返回QApplication
!这有时被称为&#34; most vexing parse&#34;。
要实际构建应用程序对象,需要提供程序的参数:
QApplication app(argc, argv);
然后是完整的程序
#include <QMessageBox>
#include <QApplication>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QMessageBox msgBox(QMessageBox::Critical,
QObject::tr("text1"),
QObject::tr("text2"),
QMessageBox::Ok);
msgBox.exec();
return 0;
}