当前位置:   article > 正文

Qt5.12实战之基本数据类型_qt6 endl not declared qt::endl

qt6 endl not declared qt::endl

注: macosx下要加上 #include <QIODevice> //for macosx

endl替换为Qt::endl;

示例源码:

  1. #include <QCoreApplication>
  2. #include <QDebug>
  3. #include <QTextStream>
  4. static QTextStream cout (stdout,QIODevice::WriteOnly);
  5. #include <iostream>
  6. #include <QtGlobal>
  7. void test()
  8. {
  9. qDebug() << "HelloWorld-qdebug";
  10. cout << "Helloword-QTextStream" <<endl;
  11. std::cout<<"Helloword-std::cout"<<std::endl;
  12. }
  13. void test_types()
  14. {
  15. qint8 signed_char_type;//signed char 有符号8bit
  16. qint16 signed_short_type;//signed short 有符号16bit
  17. qint32 signed_int_type;//signed int 有符号32bit
  18. qint64 signed_long_long_int_type;//signed long long int 有符号64bit
  19. qDebug() <<"sizeof(qint8)=" <<sizeof (signed_char_type)
  20. <<"sizeof(qint16)=" <<sizeof (signed_short_type)
  21. <<"sizeof(qint32)=" <<sizeof(signed_int_type)
  22. <<"sizeof(qint64)=" <<sizeof (signed_long_long_int_type)<<endl;;
  23. qptrdiff qint32_or_qint64_type;//32位系统 qint32 64位系统 qint64
  24. qreal double_or_float_type;//默认是double,如果加上-qreal float选项,那么是float
  25. qintptr same_as_qptrdiff;//32位系统 qint32 64位系统 qint64
  26. quintptr quint32_or_quint64_type;//32位系统 quint32 64位系统 quint64
  27. qDebug() <<"sizeof(qptrdiff)=" <<sizeof (qint32_or_qint64_type)
  28. <<"sizeof(qreal)=" <<sizeof (double_or_float_type)
  29. <<"sizeof(qintptr)=" <<sizeof(same_as_qptrdiff)
  30. <<"sizeof(quintptr)=" <<sizeof (quint32_or_quint64_type)<<endl;
  31. quint8 unsigned_char_type;//unsigned char 无符号8bit
  32. quint16 unsigned_short_type;//unsigned short 无符号16bit
  33. quint32 unsigned_int_type;//unsigned int 无符号32bit
  34. quint64 unsigned_long_long_int_type;//unsigned long long int 无符号64bit
  35. qDebug() <<"sizeof(quint8)=" <<sizeof (unsigned_char_type)
  36. <<"sizeof(quint16)=" <<sizeof (unsigned_short_type)
  37. <<"sizeof(quint32)=" <<sizeof(unsigned_int_type)
  38. <<"sizeof(quint64)=" <<sizeof (unsigned_long_long_int_type)<<endl;
  39. qlonglong same_as_qint64_type;//相当于qint64
  40. qulonglong same_as_quint64_type;//相当于quint64
  41. qDebug() <<"sizeof(qlonglong)=" <<sizeof (same_as_qint64_type)
  42. <<"sizeof(qulonglong)=" <<sizeof (same_as_quint64_type)<<endl;
  43. uchar unsigned_char_type_same_quint8;//unsigned char 无符号8bit
  44. ushort unsigned_short_type_same_quint16;//unsigned short 无符号16bit
  45. uint unsigned_int_type_same_quint32;//unsigned int 无符号32bit
  46. ulong unsigned_long_type;//unsigned long 无符号32bit
  47. qDebug() <<"sizeof(uchar)=" <<sizeof (unsigned_char_type_same_quint8)
  48. <<"sizeof(ushort)=" <<sizeof (unsigned_short_type_same_quint16)
  49. <<"sizeof(uint)=" <<sizeof(unsigned_int_type_same_quint32)
  50. <<"sizeof(ulong)=" <<sizeof (unsigned_long_type)<<endl;
  51. }
  52. int main(int argc, char *argv[])
  53. {
  54. QCoreApplication a(argc, argv);
  55. test();
  56. test_types();
  57. return a.exec();
  58. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/81639
推荐阅读
  

闽ICP备14008679号