1

I have a QTableWidget in which the user will define some text, some background and text color, and some spanning (merged cells). My problem now is to save all this once done by the user.

I'm thinking about scanning all row, all columns, get these properties, and right a custom txt or whatever file. I can then parse this file to load back the datas.

Actually I do a prototype with this : writing a QTableWidget to a .csv or .xls But saving to csv doesn't handle colors and spanning.

So before writing my own 'format' I would know if there is a standard format for this ? What would python gurus do in such case ?

Thanks Kib

Community
  • 1
  • 1
KiboOst
  • 43
  • 1
  • 4

1 Answers1

0

Use the QSettings class to store your application settings:

  • Columns: For the width and height use QHeaderView::saveState() and QHeaderView::restoreState()
  • Colors:

    Because QVariant is part of the QtCore library, it cannot provide conversion functions to data types such as QColor, QImage, and QPixmap, which are part of QtGui. In other words, there is no toColor(), toImage(), or toPixmap() functions in QVariant.

    Instead, you can use the QVariant::value() or the qVariantValue() template function

For the data a .csv file is fine.
  • Dunno if QSettings can save cell colors and span ? Anyway I don't need these datas in registry ot another ini file. I've finnally wrote my own functions to write all table datas in a file and parse it at loading. Thansk anyway for pointing to QSettings, didn't know this and it can help in other projects. – KiboOst Mar 21 '13 at 11:48
  • @KiboOst Checkout my [updated post](http://stackoverflow.com/a/15529334/1006989), I added some more information –  Mar 21 '13 at 12:09