QMessageBox::warning(this,tr("Error"),
tr("File existed"));我用QtCreator表示MSVS2012,Win7。"this“指向从QWizard类继承的一个公共类,编译器输出是
错误C2665:“QMessageBox::警告”:4个重载中没有一个可以转换所有参数类型个重载中没有一个可以转换所有参数类型可能是“QMessageBox::StandardButton QMessageBox::警告”(QWidget *、const QString &、const QString &、QMessageBox::StandardButtons、QMessageBox::StandardButton)“尝试匹配参数列表”(const newWizard *const、QString、QString)“时”
这意味着这4种重载都不能转换所有参数类型。有人能帮我吗?
发布于 2013-07-21 20:53:18
将this替换为0,它应该可以工作。
基本上,对话框不需要父程序。它可以独立存在,没有问题。
https://qt-project.org/doc/qt-4.8/objecttrees.html
正如对您的问题的评论所述,您也不能在const方法中调用警告。
另一种选择是,您可以摆脱const的newWizard()方法的特性。
希望这能有所帮助。
发布于 2013-07-22 02:18:47
尝试将this转换为QWidget *,我同意@phyatt,您可以设置parent = 0。这意味着您的警告没有父级,并且是桌面的子项。
例如:
QMessageBox::warning((QWidget *)this,tr("Error"),
tr("File existed"));
QMessageBox::warning(0,tr("Error"),
tr("File existed"));https://stackoverflow.com/questions/17773502
复制相似问题