QMap<QString,QMap<QString,QVariant> > > > Dep;
由于界面很难使用,我只需要进行微调,我想保持结构不变,尽管可能还需要一些重构.
但为了能够理解发生了什么,目前我只是放了一些qDeBUG()<<德普;在那里,并尝试了解输出. 问题是它根本没有格式化.有没有人知道一个小脚本来创建一个更好理解的显示格式?或者可能是Qt的一些补丁? 举个例子来说明我的痛苦:
QMap(("Test enable|test enable block",QMap(("Disabled",QMap(("testblock1",QMap(("enableblock",QVariant(QString,"false") ) ) ) ) ) ( "enabled","true") ) ) ) ) ) ) ) ( "Test enable|test enable key",QMap(("testblock1|testkey",QMap(("enablekey","true") ) ) ) ) ) ) ) ( "testinsertitems|Insert item",QMap(("test1",QMap(("testinsertitems|testinsert",QMap(("insertitems",QVariant(QVariantMap,"test1") ) ) ) ) ) ) ( "testinsertitems|testremove",QMap(("removeitems","test1") ) ) ) ) ) ) ) ) ( "test2",QMap(("test2","test2") ) ) ) ) ) ) ( "testinsertitems|testremove","test2") ) ) ) ) ) ) ) ) ) ) ( "testsetminmax|test setmin",QMap(("2",QMap(("testsetminmax|testkey1",QMap(("setmin",QVariant(int,2) ) ) ) ( "testsetminmax|testkey2",QMap(("setmax",2) ) ) ) ) ) ( "3",3) ) ) ) ( "testsetminmax|testkey2",3) ) ) ) ) ) ) ) ( "testsetvalue|test set value",QMap(("testsetvalue|testkey1",QMap(("setvalue","2") ) ) ) ( "testsetvalue|testkey2","2") ) ) ) ( "testsetvalue|testkey3","2") ) ) ) ) ) ( "3","3") ) ) ) ( "testsetvalue|testkey2","3") ) ) ) ( "testsetvalue|testkey3","3") ) ) ) ) ) ) ) )
谢谢
解决方法 这个用于n维,并将使用已知类型的标准qDeBUG输出:template<class NonMap>struct Print{ static voID print(const QString& tabs,const NonMap& value) { qDeBUG() << tabs << value; }};template <class Key,class ValueType >struct Print<class QMap<Key,ValueType> >{ static voID print(const QString& tabs,const QMap< Key,ValueType>& map ) { const QString extraTab = tabs + "\t"; QMAPIterator<Key,ValueType> iterator(map); while(iterator.hasNext()) { iterator.next(); qDeBUG() << tabs << iterator.key(); Print<ValueType>::print(extraTab,iterator.value()); } }};template<class Type>voID printMe(const Type& type ){ Print<Type>::print("",type);};总结
以上是内存溢出为你收集整理的c – 格式化qDebug for QMaps的输出全部内容,希望文章能够帮你解决c – 格式化qDebug for QMaps的输出所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)