Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a good read for the best practices for <a href="http://doc.qt.nokia.com/latest/model-view-programming.html#model-classes" rel="nofollow">Model/View Programming in Qt</a>.</p> <p>The examples and links at the bottom of the above link are nice, too.</p> <p>As for storing multiple types, I would look at <a href="http://doc.qt.nokia.com/latest/qvariant.html" rel="nofollow">QVariant</a> and QSettings; using QVariant is referenced many times in the Model/View Programming in Qt.</p> <p>QVariant is very robust and works well with many different types. It is core in reading values out of QSettings. Be sure to read the description of QSettings for more ideas.</p> <pre><code> QBitArray toBitArray () const bool toBool () const QByteArray toByteArray () const QChar toChar () const QDate toDate () const QDateTime toDateTime () const double toDouble ( bool * ok = 0 ) const QEasingCurve toEasingCurve () const float toFloat ( bool * ok = 0 ) const QHash&lt;QString, QVariant&gt; toHash () const int toInt ( bool * ok = 0 ) const QLine toLine () const QLineF toLineF () const QList&lt;QVariant&gt; toList () const QLocale toLocale () const qlonglong toLongLong ( bool * ok = 0 ) const QMap&lt;QString, QVariant&gt; toMap () const QPoint toPoint () const QPointF toPointF () const qreal toReal ( bool * ok = 0 ) const QRect toRect () const QRectF toRectF () const QRegExp toRegExp () const QSize toSize () const QSizeF toSizeF () const QString toString () const QStringList toStringList () const QTime toTime () const uint toUInt ( bool * ok = 0 ) const qulonglong toULongLong ( bool * ok = 0 ) const QUrl toUrl () const </code></pre> <p>Another good option is QString. It has a number of built in conversions also:</p> <pre><code> QByteArray toAscii () const QString toCaseFolded () const double toDouble ( bool * ok = 0 ) const float toFloat ( bool * ok = 0 ) const int toInt ( bool * ok = 0, int base = 10 ) const QByteArray toLatin1 () const QByteArray toLocal8Bit () const long toLong ( bool * ok = 0, int base = 10 ) const qlonglong toLongLong ( bool * ok = 0, int base = 10 ) const QString toLower () const short toShort ( bool * ok = 0, int base = 10 ) const std::string toStdString () const std::wstring toStdWString () const uint toUInt ( bool * ok = 0, int base = 10 ) const ulong toULong ( bool * ok = 0, int base = 10 ) const qulonglong toULongLong ( bool * ok = 0, int base = 10 ) const ushort toUShort ( bool * ok = 0, int base = 10 ) const QVector&lt;uint&gt; toUcs4 () const QString toUpper () const QByteArray toUtf8 () const int toWCharArray ( wchar_t * array ) const </code></pre> <p>When saving numerical values to a QString, be sure to use QString::number().</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload