【发布时间】:2013-05-21 08:30:26
【问题描述】:
当我编译这段代码时
QVector<QString> taskTitle({"Movies which are directed by Steven Spilberg",
"All those who have reviewed Gone whith the wind",
"Summation of Gone with the wind scores",
"All years which has a movie whith 5 or 4 scores increasingly sortd"});
编译器给了我:
error: no matching function for call to
'QVector<QString>::QVector(<brace-enclosed initializer list>)'
我也用过:
QVector<QString> taskTitle={"Movies which are directed by Steven Spilberg",
"All those who have reviewed Gone whith the wind",
"Summation of Gone with the wind scores",
"All years which has a movie whith 5 or 4 scores increasingly sortd"};
又一次:
error: in C++98 'taskTitle' must be initialized by constructor, not by '{...}'
我的编译器是 MinGW,并带有 QT 5.0.1 我能做什么?
【问题讨论】:
-
您是否有 C++11 兼容的编译器并设置了适当的编译标志 (-std=c++11)?你有什么版本的Qt?请更新问题并添加有关您的构建的其他信息。
-
我的编译器是 MinGW 并附带 QT 5.0.1
-
如果您使用
qmake,您的.pro文件中是否有QMAKE_CXXFLAGS += -std=c++11(或类似名称)?或者,如果您不能将构建脚本附加到问题中? -
没有所有的东西:QT += core QT -= gui QT +=sql TARGET = Sqlite CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp跨度>
-
@MrHsCE 照fasked所说的去做,这就是你的解决方案。
标签: qt vector initializer-list