Hi,

I am trying, using QSettings, to serialise various settings, which are of type QList<int>. Now, it all works fine on Windows and OS X, but for some reasons it doesn't on Linux. Here is how I do it to load and save some of those settings. Notice that I register QList<int> as a meta-type (using qRegisterMetaTypeStreamOperators), so I believe I should be all fine and, indeed, it all works as I would expect on Windows and OS X, but not on Linux. On Linux, I get a bunch of warnings like:

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::save: unable to save type 'QList<int>' (type id: 1038).

QVariant::load: unable to load type 1038.
QVariant::load: unable to load type 1038.
Just out of curiosity, I thought I would try loading/saving my settings in a different way by using QVariantList. Thus, for loading my settings, I have something like:

Qt Code:
  1. void CellmlAnnotationViewWidget::loadSettings(QSettings *pSettings)
  2. {
  3. // Retrieve the sizes of our editing widget and of its metadata details
  4. // Note: we would normally do this in CellmlAnnotationViewEditingWidget, but
  5. // we have one instance of it per CellML file and we want to share
  6. // some information between the different instances, so we have to do
  7. // it here instead...
  8.  
  9. QVariantList defaultEditingWidgetSizes = QVariantList() << 0.25*qApp->desktop()->screenGeometry().width()
  10. << 0.75*qApp->desktop()->screenGeometry().width();
  11. QVariantList defaultMetadataDetailsWidgetSizes = QVariantList() << 0.25*qApp->desktop()->screenGeometry().height()
  12. << 0.25*qApp->desktop()->screenGeometry().height()
  13. << 0.50*qApp->desktop()->screenGeometry().height();
  14.  
  15. QVariantList editingWidgetSizes = pSettings->value(SettingsCellmlAnnotationViewEditingWidgetSizes, defaultEditingWidgetSizes).toList();
  16. QVariantList metadataDetailsWidgetSizes = pSettings->value(SettingsCellmlAnnotationViewMetadataDetailsWidgetSizes, defaultMetadataDetailsWidgetSizes).toList();
  17.  
  18. foreach (const QVariant &editingWidgetSize, editingWidgetSizes)
  19. mEditingWidgetSizes << editingWidgetSize.toInt();
  20.  
  21. foreach (const QVariant &metadataDetailsWidgetSize, metadataDetailsWidgetSizes)
  22. mMetadataDetailsWidgetSizes << metadataDetailsWidgetSize.toInt();
  23. }
To copy to clipboard, switch view to plain text mode 

while for saving them, I have something like:

Qt Code:
  1. void CellmlAnnotationViewWidget::saveSettings(QSettings *pSettings) const
  2. {
  3. // Keep track of the sizes of our editing widget and of its metadata details
  4.  
  5. QVariantList editingWidgetSizes = QVariantList();
  6. QVariantList metadataDetailsWidgetSizes = QVariantList();
  7.  
  8. foreach (const int &editingWidgetSize, mEditingWidgetSizes)
  9. editingWidgetSizes << editingWidgetSize;
  10.  
  11. foreach (const int &metadataDetailsWidgetSize, mMetadataDetailsWidgetSizes)
  12. metadataDetailsWidgetSizes << metadataDetailsWidgetSize;
  13.  
  14. pSettings->setValue(SettingsCellmlAnnotationViewEditingWidgetSizes, editingWidgetSizes);
  15. pSettings->setValue(SettingsCellmlAnnotationViewMetadataDetailsWidgetSizes, metadataDetailsWidgetSizes);
  16. }
To copy to clipboard, switch view to plain text mode 

Now, the interesting bit is that... it works on Windows, OS X and... also Linux! So, could it be that I have just come across a bug with Qt (5.2.1) on Linux?...

Whatever the case, even though using QVariantList does indeed 'fixes' my problem, I would rather use my original approach, if possible (I find 'cleaner'). This aside, I am curious as what I have done wrong, if anything, in my original approach. Anyone?

Cheers, Alan.