I’m having a weird error when trying to use ‘QJsonObject::iterator’ with MSVC2013.
I have the following example:
#include <QCoreApplication>
#include <QJsonObject>
#include <QDebug>
#include <algorithm>
void processValue(QJsonValue value) {
qDebug() << value.toString();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QJsonObject jsonObject;
jsonObject.insert("a", "A");
jsonObject.insert("b", "B");
jsonObject.insert("c", "C");
jsonObject.insert("d", "D");
jsonObject.insert("e", "E");
std::for_each (jsonObject.begin(), jsonObject.end(), processValue);
return a.exec();
}
This code compiles and works as expected with MSVC2008 (cross-compiling to WinCE) and MinGW, but not with MSVC2013. In all cases, I’m using Qt 5.5.1.
The error message is:
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2039: 'pointer' : is not a member of 'QJsonObject::iterator'
c:qtqt5.5.1msvc5.5msvc2013includeqtcoreqjsonobject.h(96) : see declaration of 'QJsonObject::iterator'
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(584) : see reference to class template instantiation 'std::iterator_traits<_InIt>' being compiled
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDEalgorithm(31) : see reference to function template instantiation 'void std::_Debug_range<_InIt>(_InIt,_InIt,std::_Dbfile_t,std::_Dbline_t)' being compiled
with
[
_InIt=QJsonObject::iterator
]
..QJsonObjectIteratorIssuemain.cpp(21) : see reference to function template instantiation '_Fn1 std::for_each<QJsonObject::iterator,void(__cdecl *)(QJsonValue)>(_InIt,_InIt,_Fn1)' being compiled
with
[
_Fn1=void (__cdecl *)(QJsonValue)
, _InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2146: syntax error : missing ';' before identifier 'pointer'
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2602: 'std::iterator_traits<_InIt>::pointer' is not a member of a base class of 'std::iterator_traits<_InIt>'
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : see declaration of 'std::iterator_traits<_InIt>::pointer'
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2868: 'std::iterator_traits<_InIt>::pointer' : illegal syntax for using-declaration; expected qualified-name
with
[
_InIt=QJsonObject::iterator
]
Am I doing anything wrong here, that just happen to work by chance on the 2 other compilers?
SkillKota 0 / 0 / 0 Регистрация: 23.11.2015 Сообщений: 13 |
|||||||||||||||||||||||||
1 |
|||||||||||||||||||||||||
09.04.2017, 18:22. Показов 4880. Ответов 9 Метки нет (Все метки)
Есть mainwindow и chat.
mainwindow.cpp
chat.cpp
mainwindow.h
chat.h
0 |
1068 / 650 / 229 Регистрация: 14.01.2016 Сообщений: 2,031 Записей в блоге: 9 |
|
09.04.2017, 20:06 |
2 |
chat.cpp:10: ошибка: C2039: Show: не является членом «chat» 1) chat не может быть показан тк не является виджетом(QWidget).
0 |
0 / 0 / 0 Регистрация: 23.11.2015 Сообщений: 13 |
|
12.04.2017, 08:37 [ТС] |
3 |
А как мне сделать так,что при нажатии кнопки открывалась другая форма,а первая закрывалась?
0 |
1068 / 650 / 229 Регистрация: 14.01.2016 Сообщений: 2,031 Записей в блоге: 9 |
|
12.04.2017, 11:04 |
4 |
SkillKota, Если нужно только это, то пускай первая форма генерирует сигнал открытия для другой, с bool значением. Затем можно данный сигнал подсоединить к слоту setVisible у другой формы. А затем скрыть первую форму.
0 |
SkillKota 0 / 0 / 0 Регистрация: 23.11.2015 Сообщений: 13 |
||||||||||||||||||||
13.04.2017, 22:01 [ТС] |
5 |
|||||||||||||||||||
Я уже пару дней бъюсь с сигналами и слотами.Вот,что я попытался сделать.
mainwindow.cpp
mainwindow.h
chat.cpp
chat.h
0 |
1068 / 650 / 229 Регистрация: 14.01.2016 Сообщений: 2,031 Записей в блоге: 9 |
|
14.04.2017, 11:08 |
6 |
MainWindow *mw=new MainWindow(); Объясните, что вы пытаетесь сделать этой строкой?
0 |
0 / 0 / 0 Регистрация: 23.11.2015 Сообщений: 13 |
|
15.04.2017, 23:38 [ТС] |
7 |
Пытаюсь сделать ссылку,чтобы обратиться к MainWindow
0 |
1068 / 650 / 229 Регистрация: 14.01.2016 Сообщений: 2,031 Записей в блоге: 9 |
|
18.04.2017, 10:00 |
8 |
Пытаюсь сделать ссылку,чтобы обратиться к MainWindow MainWindow — это класс, а не объект, он не существует и к нему нельзя обратиться.
0 |
0 / 0 / 0 Регистрация: 23.11.2015 Сообщений: 13 |
|
18.04.2017, 18:33 [ТС] |
9 |
Я знаю С++ на базовом уровне. Я не могу понять, как обратиться к форме.
0 |
1068 / 650 / 229 Регистрация: 14.01.2016 Сообщений: 2,031 Записей в блоге: 9 |
|
18.04.2017, 21:35 |
10 |
Я знаю С++ на базовом уровне. Я не могу понять, как обратиться к форме. Если бы вы знали С++, вы бы понимали, какую чушь вы творите. Я же не просто так говорю.
0 |
Update: Forum Guidelines & Code of Conduct
This topic has been deleted. Only users with topic management privileges can see it.
-
hi
i’m new to qt. i have installed qt 5.5.1 for 32 bit windows 7 with microsoft visual studio 2012. I have cloned the source code of Qgroundcontrol through github desktop. when i try to build and compile the source code i am getting errrors as C2039 ‘isfinite’ is not a member of namespace ‘std’ -
Probably you did not activate C++11 standard.
std::isfinite was invented in C++11, see http://en.cppreference.com/w/cpp/numeric/math/isfinite
I’m not sure, but probably VS2012 C++ compiler does not support C++11.
У меня странная ошибка при попытке использовать ‘QJsonObject :: iterator’ с MSVC2013.
У меня есть следующий пример:
#include <QCoreApplication>
#include <QJsonObject>
#include <QDebug>
#include <algorithm>
void processValue(QJsonValue value) {
qDebug() << value.toString();
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QJsonObject jsonObject;
jsonObject.insert("a", "A");
jsonObject.insert("b", "B");
jsonObject.insert("c", "C");
jsonObject.insert("d", "D");
jsonObject.insert("e", "E");
std::for_each (jsonObject.begin(), jsonObject.end(), processValue);
return a.exec();
}
Этот код компилируется и работает, как ожидается, с MSVC2008 (перекрестная компиляция в WinCE) и MinGW, но не с MSVC2013. Во всех случаях я использую Qt 5.5.1.
Сообщение об ошибке:
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2039: 'pointer' : is not a member of 'QJsonObject::iterator'
c:qtqt5.5.1msvc5.5msvc2013includeqtcoreqjsonobject.h(96) : see declaration of 'QJsonObject::iterator'
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(584) : see reference to class template instantiation 'std::iterator_traits<_InIt>' being compiled
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDEalgorithm(31) : see reference to function template instantiation 'void std::_Debug_range<_InIt>(_InIt,_InIt,std::_Dbfile_t,std::_Dbline_t)' being compiled
with
[
_InIt=QJsonObject::iterator
]
..QJsonObjectIteratorIssuemain.cpp(21) : see reference to function template instantiation '_Fn1 std::for_each<QJsonObject::iterator,void(__cdecl *)(QJsonValue)>(_InIt,_InIt,_Fn1)' being compiled
with
[
_Fn1=void (__cdecl *)(QJsonValue)
, _InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2146: syntax error : missing ';' before identifier 'pointer'
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2602: 'std::iterator_traits<_InIt>::pointer' is not a member of a base class of 'std::iterator_traits<_InIt>'
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : see declaration of 'std::iterator_traits<_InIt>::pointer'
with
[
_InIt=QJsonObject::iterator
]
C:Program Files (x86)Microsoft Visual Studio 12.0VCINCLUDExutility(375) : error C2868: 'std::iterator_traits<_InIt>::pointer' : illegal syntax for using-declaration; expected qualified-name
with
[
_InIt=QJsonObject::iterator
]
Я делаю что-то здесь не так, что это случайно произошло с двумя другими компиляторами?
0
Решение
Другие решения
Других решений пока нет …
Windows Visual Studio 2010. Qt 4.7.1
При выполнении команд
qmake CONFIG-=debug_and_release CONFIG-=debug -recursive vacuum.pro
nmake
nmake install
Сборка не проходит. Выводит ошибки:
.optionsmanager.cpp(183) : error C2039: nativeLanguageName: не является членом «QLocale»
c:qt4.7.1includeqtcore../../src/corelib/tools/qlocale.h(110): см. объявление «QLocale»
.optionsmanager.cpp(184) : error C2039: nativeCountryName: не является членом «QLocale»
c:qt4.7.1includeqtcore../../src/corelib/tools/qlocale.h(110): см. объявление «QLocale»
Ошибка вот тут:
QString langName = locale.nativeLanguageName();
QString QLocale::nativeLanguageName() const
This function was introduced in Qt 4.8.
В инфе по сборке у Вас указано QT 4.5.2