Найти - Пользователи
Полная версия: Qvariant туда.. а обратно,?
Начало » GUI » Qvariant туда.. а обратно,?
1
124bit
def addMail(model, subject, sender, date):
model.insertRow(0)
model.setData(model.index(0, 0), QtCore.QVariant(subject))
model.setData(model.index(0, 1), QtCore.QVariant(sender))
model.setData(model.index(0, 2), QtCore.QVariant(date))




def createMailModel(parent):
model = QtGui.QStandardItemModel(0, 3, parent)

model.setHeaderData(0, QtCore.Qt.Horizontal, QtCore.QVariant("Subject"))
model.setHeaderData(1, QtCore.Qt.Horizontal, QtCore.QVariant("Sender"))
model.setHeaderData(2, QtCore.Qt.Horizontal, QtCore.QVariant("Date"))

addMail(model, "Happy New Year!", "Grace K. <grace@software-inc.com>",
QtCore.QDateTime(QtCore.QDate(2006, 12, 31), QtCore.QTime(17, 03)))
addMail(model, "Radically new concept", "Grace K. <grace@software-inc.com>",
QtCore.QDateTime(QtCore.QDate(2006, 12, 22), QtCore.QTime(9, 44)))
addMail(model, "Accounts", "pascale@nospam.com",
QtCore.QDateTime(QtCore.QDate(2006, 12, 31), QtCore.QTime(12, 50)))
addMail(model, "Expenses", "Joe Bloggs <joe@bloggs.com>",
QtCore.QDateTime(QtCore.QDate(2006, 12, 25), QtCore.QTime(11, 39)))
addMail(model, "Re: Expenses", "Andy <andy@nospam.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 02), QtCore.QTime(16, 05)))
addMail(model, "Re: Accounts", "Joe Bloggs <joe@bloggs.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 03), QtCore.QTime(14, 18)))
addMail(model, "Re: Accounts", "Andy <andy@nospam.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 03), QtCore.QTime(14, 26)))
addMail(model, "Sports", "Linda Smith <linda.smith@nospam.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 05), QtCore.QTime(11, 33)))
addMail(model, "AW: Sports", "Rolf Newschweinstein <rolfn@nospam.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 05), QtCore.QTime(12, 00)))
addMail(model, "RE: Sports", "Petra Schmidt <petras@nospam.com>",
QtCore.QDateTime(QtCore.QDate(2007, 01, 05), QtCore.QTime(12, 01)))

return model


print type(createMailModel(None))
var=QtCore.QVariant(createMailModel(None))
как мне из var обратно получить мою MailModel (QStandardItemModel type 309)?
poltergeist
var.toPyObject()

З.Ы. а зачем это вам понадобилось?
124bit
пасибо)
гм… надо вбить в файл настроек модель.. чтоб не разбирать ее по кусочкам, а сразу записать))
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB