Originally Posted by
wysota
What does it segfault on?
Some internal stream function (datastream >> QTextFormat I guess).
Can you provide a minimal compilable example reproducing the problem?
Sure! Here it comes :
#include <QSettings>
#include <QTextCharFormat>
int main(int argc, char **argv)
{
qRegisterMetaType<QTextFormat>("QTextFormat");
qRegisterMetaTypeStreamOperators<QTextFormat>("QTextFormat");
s.setValue("normal", f);
f.setForeground(Qt::red);
s.setValue("text", f);
f.setFontItalic(true);
f.setForeground(Qt::darkBlue);
s.setValue("comment", f);
f.setForeground(Qt::lightGray);
s.setValue("doxygen", f);
f.setForeground(Qt::black);
f.setFontWeight(10);
f.setFontItalic(false);
s.setValue("text", f);
s.sync();
foreach ( const QString& key, s.allKeys() )
f = qvariant_cast<QTextFormat>(s.value(key)).toCharFormat();
return 0;
}
#include <QSettings>
#include <QTextCharFormat>
Q_DECLARE_METATYPE(QTextFormat)
int main(int argc, char **argv)
{
qRegisterMetaType<QTextFormat>("QTextFormat");
qRegisterMetaTypeStreamOperators<QTextFormat>("QTextFormat");
QSettings s("formats.ini", QSettings::IniFormat);
QTextCharFormat f;
s.setValue("normal", f);
f.setForeground(Qt::red);
s.setValue("text", f);
f.setFontItalic(true);
f.setForeground(Qt::darkBlue);
s.setValue("comment", f);
f.setForeground(Qt::lightGray);
s.setValue("doxygen", f);
f.setForeground(Qt::black);
f.setFontWeight(10);
f.setFontItalic(false);
s.setValue("text", f);
s.sync();
foreach ( const QString& key, s.allKeys() )
f = qvariant_cast<QTextFormat>(s.value(key)).toCharFormat();
return 0;
}
To copy to clipboard, switch view to plain text mode
Bookmarks