qt4怎么实现对qt4 json解析的生成和解析,不是qt5

qt4如何实现对json的生成和解析,不是qt5
我现在需要用qt实现对json的生成和解析,需要包含多个子级的。目前我只有解析的方法,是从网上找的,谁能提供一下,qt对json的生成的方法,不胜感激。
cJSON,看看这个吧。
即使是一小步也想与你分享From Qt Wiki
The transition from Qt 4.x to Qt 5 is not expected to be significant. However, the "modularization" of the Qt code base requires some amount of changes to project configuration, such as use of "headers", and configuration of project build settings (such as changes to the *.pro files).
Qt Creator (master) is compiled using Qt 4 and Qt 5; you can refer to its sources to get an overview of what is required to port an application and keep the sources backwards compatible to Qt 4.
error: QMainWindow: No such file or directory
error: QToolButton: No such file or directory
error: QWidget: No such file or directory
Add this in your *.pro file:
QT += widgets
Change all instances of
#include &QtGui&
#include &QtWidgets&
The code should work now, though sometimes you may require to be more explicit:
#include &QtWidgets/QToolButton&
error: invalid use of incomplete type 'class QWebFrame'
error: forward declaration of 'class QWebFrame'
Add this in your *.pro file:
QT += webkitwidgets
Note: when you have QT += webkitwidgets you don't need QT += widgets
In addition, replace all instances of
#include &QtWebKit&
#include &QtWebKitWidgets&
You can try this by porting a
from Qt 4 to Qt 5.
If your code has the following lines:
#include &QPrinter&
#include &QPrintDialog&
add the following to your project file:
QT += printsupport
Again, sometimes it may not work and you would need to be explicit:
#include &QtPrintSupport/QPrinter&
#include &QtPrintSupport/QPrintDialog&
Replace all instances of
fromAscii()
toAscii()
fromLatin1()
toLatin1()
For example, given the Qt 4 code
QByteArray configfileti = TMP_Config.toAscii();
you would change to
QByteArray configfileti = TMP_Config.toLatin1();
This enum type used to define the 8-bit encoding of character string arguments to translate(). This enum is now obsolete and UTF-8 will be used in all cases. So remove all instances of QCoreApplication::UnicodeUTF8. For example:
Href_Gui-&setWindowTitle(QApplication::translate(&Href_Gui&, &Url / www&, 0, QApplication::UnicodeUTF8));
label-&setText(QApplication::translate(&Href_Gui&, &Text:&, 0, QApplication::UnicodeUTF8));
label_2-&setText(QApplication::translate(&Href_Gui&, &Url:&, 0, QApplication::UnicodeUTF8));
label_3-&setText(QApplication::translate(&Href_Gui&, &Target / Name:&, 0, QApplication::UnicodeUTF8));
Href_Gui-&setWindowTitle(QApplication::translate(&Href_Gui&, &Url / www&, 0));
label-&setText(QApplication::translate(&Href_Gui&, &Text:&, 0));
label_2-&setText(QApplication::translate(&Href_Gui&, &Url:&, 0));
label_3-&setText(QApplication::translate(&Href_Gui&, &Target / Name:&, 0));
This class is obsolete and was replaced by the QMdiArea class in Qt 4.3. In Qt 5 QWorkspace has been removed. The new class has a similar API to QWorkspace and porting it only involved changing the names of a few methods, signals, and slots.
#include &QWorkspace&
#include &QMdiArea&
Apps that have drop and drag functionality will need some tweaking. A line such as
QDrag *drag = new QDrag(event-&widget());
in Qt 5 will generate the error
error: no matching function for call to 'QDrag::QDrag(QWidget*)'
To fix this add among the includes:
#include &QWidget&
An error will pop of this fashion:
error: 'qFindChildren' was not declared in this scope
To solve this you replace qFindChildren with findChildren, for example in
toString(const QObject* obj, int indentLevel) const {
[…]
/* Query over QObjects */
if (m_children) {
QList&QObject*& childlist = qFindChildren&QObject*&(obj, QString());
[…]
QList&QObject*& childlist = qFindChildren&QObject*&(obj, QString());
QList&QObject*& childlist = obj-&findChildren&QObject*&(QString());
Your compiler will say
error: 'qVariantValue' was not declared in this scope
This function is equivalent to QVariant::value&T&(value). Therefore if given a QVariant val rewrite the line
QTime t = qVariantValue&QTime&(val);
QTime t = val.value&QTime&();
This QTime enclosed in the angled brackets lets the compiler know what QVariant will return. However, if the variable is not a QVariable the type enclosed in the angled brackets should not be used(doing so will result in a vague compile time error). So given that m_color is of type QColor you will rewrite
s.setValue(&color/favorite&, qVariantValue&QColor&(m_color));
s.setValue(&color/favorite&, m_color.value());
Q_ASSERT(qVariantCanConvert&QString&(variant));
Q_ASSERT(qVariantCanConvert&QSize&(variant));
Q_ASSERT(qVariantCanConvert&QFont&(fontVariant));
Q_ASSERT(variant.canConvert(QMetaType::QString));
Q_ASSERT(variant.canConvert(QMetaType::QSize));
Q_ASSERT(fontVariant.canConvert(QMetaType::QFont));
error: 'escape' is not a member of 'Qt'
So you would change the following block:
if (result == QString())
result = Qt::escape(val.toString());
result = Qt::escape(result);
return result;
if (result == QString())
result = QString(val.toString()).toHtmlEscaped();
result = QString(result).toHtmlEscaped();
return result;
this procedure can be automated by a
from KDAB.
error: 'storageLocation' is not a member of 'QDesktopServices'
error: 'DataLocation' is not a member of 'QDesktopServices'
Use QStandardPaths::StandardLocation:
QString path = s.value(&db.path&, QDesktopServices::storageLocation(QDesktopServices::DataLocation)).toString();
QString path = s.value(&db.path&, QStandardPaths::standardLocations(QStandardPaths::DataLocation)).toString();
If you have the above line in your project file the compiler will warn you in the compile window, nonetheless the code will still run as usual:
Project WARNING: CONFIG+=qtestlib is deprecated. Use QT+=testlib instead.
A code block like
quint64 decodedPointer = line.toULongLong();
MetaData* md = reinterpret_cast&MetaData*&(decodedPointer);
QWeakPointer&MetaData& wp(md);
results in
error: no matching function for call to 'QWeakPointer&MetaData&::QWeakPointer(MetaData*&)'
To fix this add to the project file:
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
C:\Qt\5.0.2\5.0.2\mingw47_32\include\QtConcurrent\qtconcurrentthreadengine.h:133: error: undefined reference to
`_imp___ZN12QtConcurrent16ThreadEngineBaseD2Ev'
In Qt 4, QtConcurrent was part of QtCore, so there was no need to include specific headers. This is no longer the case with Qt 5. If your source code has lines like
m_current = QtConcurrent::blockingMappedReduced(slices, functor, stitchReduce, QtConcurrent::UnorderedReduce );
You will need to include the header:
#include &QtConcurrent/QtConcurrent&
and add the following line to your project file:
QT+= concurrent
A Perl script "fixqt4headers.pl" exists in qtbase/bin/. that should be run on source code using Qt that corrects the #include&& directives for Qt components to also consider the module name.
The Q_EXPORT_PLUGIN,Q_EXPORT_PLUGIN2 macros have been deprecated in favor of the new Q_PLUGIN_METADATA macro. The advantage of the new system is that it allows Qt to query the metadata for the plugin without actually dlopen'ing it. This greatly improves performance and reliability of the plugin system.
The new Q_PLUGIN_METADATA macro is included next to the Q_OBJECT macro in the QObject derived class that is returned when loading the plugin. It contains the plugins IID and a filename pointing to a json file containing the metadata for the plugin. The json file is compiled into the plugin and does not need to be installed.
An example on how to change your plugins can be found by looking at the patch that changes the Gif image format plugin, see
When Qt is built from source code on a system with C++11 installed, the Qt libraries/frameworks are linked against the system's C++11 library (libc). This means that the Qt libraries/frameworks are not deployable to systems without C++11 installed (such as out-of-the-box Mac OS X 10.6). To be able to deploy to systems that only support the older C++ standard (libstdc++), build Qt from source code with the -no-c++11 configure option.
QTimer has now 3 accuracy types, with a new default behaviour:
The new default type is Qt::CoarseTimer which, to reduce power/CPU consumption, allow 5% difference between requested time and actual one, and even allow the timer to fire before the requested time.
The former one is Qt::PreciseTimer (to the millisecond, never before the requested time).
A third one is Qt::VeryCoarseTimer and allow a 1 second difference
If you have:
url.addQueryItem(key, value);
You will want to change it to
QUrlQuery urlQuery;
urlQuery.addQueryItem(key, value);
url.setUrlQuery(urlQuery);
void reset()
void setRoleNames(const QHash&int, QByteArray& & roleNames)
both have changed and are now obsolete.&>&&>&&>&&>&QT4迁移至QT5完全指南
QT4迁移至QT5完全指南
上传大小:248KB
将Qt4代码迁移到Qt5还是比较简单的。实际上,在Qt5开发过程中就已经注意了与Qt4代码保持兼容性。与Qt3到Qt4的迁移不同,Qt5的核心类库并没有做大的API的改,只有几个新的类取代了旧的(例如,像Qt4的QList取代了QPtrList和QValueLitemview取代了Q3ListVgraphicsview取代Canvas API);同时也没有那些编译通过了,但运行时的行为却与之前的不一致的(例如,QWidget::show现在是非虚函数,绘制应该在paintEvent中进行等等)。
但是,迁移的代价也不会是零。本文总结了KDE部分代码从Qt4迁移到Qt5所需要注意的问题。KAddressbook迁移到Qt5和KDE Frameworks 5 KDE PIM是最后一个完整迁移到Qt4和kdelibs4的部分。迁移到Qt5应当更快些。...展开收缩
嵌到我的页面
<input type="text" value="">
综合评分:3.8(12位用户评分)
所需积分:0
下载次数:138
审核通过送C币
创建者:caozhy
创建者:hujiasuta
创建者:redleafe
课程推荐相关知识库
上传者其他资源上传者专辑
开发技术热门标签
VIP会员动态
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
android服务器底层网络模块的设计方法
所需积分:0
剩余积分:720
您当前C币:0
可兑换下载积分:0
兑换下载分:
兑换失败,您当前C币不够,请先充值C币
消耗C币:0
你当前的下载分为234。
QT4迁移至QT5完全指南
会员到期时间:
剩余下载次数:
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可奖励20下载分
被举报人:
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:}

我要回帖

更多关于 qt5解析json 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信