• 9545阅读
  • 6回复

【提问】求各位帮我看看这个编译错误。 [复制链接]

上一主题 下一主题
离线kytexzy
 

只看楼主 倒序阅读 楼主  发表于: 2005-09-09
小弟近日初学Qt的容器类,想演示一下Qt文档里的例子:
#include <QApplication>
#include <QString>
#include <QListIterator>

int main(int argc, char *argv[])

{

  QApplication app(argc, argv);



  QList<QString> list;
  list << "A" << "B" << "C" << "D";
 
  QListIterator<QString> i(list);
  while (i.hasNext() ) {
    qDebug() << i.next();
  }

  return app.exec();

}

编译时提示一大堆错误:
main.cpp: In function ‘int main(int, char**)’:
/usr/include/qt4/QtCore/qglobal.h:1047: error: too few arguments to function ‘void qDebug(const char*, ...)’
main.cpp:14: error: at this point in file
main.cpp:14: error: no match for ‘operator<<’ in ‘qDebug(<expression error>) << i. QListIterator<T>::next [with T = QString]()’
/usr/include/qt4/QtCore/qchar.h:294: note: candidates are: QDataStream& operator<<(QDataStream&, const QChar&)
/usr/include/qt4/QtCore/qbytearray.h:497: note:           QDataStream& operator<<(QDataStream&, const QByteArray&)
.........

难道是qDebug()的用法不对吗?我有点晕了。

求高人一点迷津。
try to find forgiveness for yourself and forgive others
离线XChinux

只看该作者 1楼 发表于: 2005-09-09
人家说你qDebug()参数太少了...参数不正确.
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线kytexzy

只看该作者 2楼 发表于: 2005-09-09
不对啊,qt assistant中的例子就是这样使用qDebug()的啊!
try to find forgiveness for yourself and forgive others
离线XChinux

只看该作者 3楼 发表于: 2005-09-09
下面是引用kytexzy于2005-09-09 17:12发表的:
不对啊,qt assistant中的例子就是这样使用qDebug()的啊!


文档里有这样一句话:
Warning: Passing (const char *)0 as argument to qDebug might lead to crashes on certain platforms due to the platform's printf() implementation.


所以你还是试验一下使用参数的形式看能否通过.
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线kytexzy

只看该作者 4楼 发表于: 2005-09-09
用参数形式也不行,编译的时候错误提示乱跳屏,我认为应该是我这个程序有问题,看那位能否改一下了。
喔,谢先一个。
try to find forgiveness for yourself and forgive others
离线myer

只看该作者 5楼 发表于: 2005-09-09
#include <qtcore>试试
http://user.qzone.qq.com/56430808
离线giscn
只看该作者 6楼 发表于: 2005-09-10
#include <QDebug>
http://nzt.spaces.live.com
快速回复
限100 字节
 
上一个 下一个