示例#1
0
 def __init__(self, parent=None):
     QWidget.__init__(self, parent)
     self.setupUi(self)
     self.retranslate(all=False)
     self.settings = QSettings()
     show = self.settings.value('showWelcome', 2).toInt()[0]
     self.checkBox.setCheckState(Qt.CheckState(show))
示例#2
0
 def __init__(self, text='', checked=0, checkable=False):
     QStandardItem.__init__(self, text)
     self.setEditable(False)
     self.setCheckable(checkable)
     if checkable:
         self.setCheckState(Qt.CheckState(2 if checked else 0))
示例#3
0
def setCheckState(o, v):
    o.setCheckState(Qt.CheckState(v.toInt()[0]))
示例#4
0
def check_state_role_handler(model, row, column):
    state = model.check_state(row, column)
    if state is not None:
        return Qt.CheckState(state)
示例#5
0
    def restoreValue(self, fail=None):

        valtype = self.attribute('type')
        value = None

        # Restore a list item
        if (valtype == 'list'):
            value = []
            for child in self.children():
                value.append(child.restoreValue())

        # Restore a dictionary item
        elif (valtype == 'dict'):
            value = {}
            for child in self.children():
                value[child.attribute('key')] = child.restoreValue()

        # Record a qdatetime
        elif (valtype == 'QDateTime'):
            value = QDateTime.fromString(self.attribute('value'),
                                         'yyyy-MM-dd hh:mm:ss')

        # Record a qdate
        elif (valtype == 'QDate'):
            value = QDate.fromString(self.attribute('value'), 'yyyy-MM-dd')

        # Restore a QRect
        elif (valtype == 'QRect'):
            value = self.findRect('rect')

        # Restore a QRectF
        elif (valtype == 'QRectF'):
            value = self.findRectF('rect')

        # Restore a QSize
        elif (valtype == 'QSize'):
            value = self.findSize('size')

        # Restore a QSizeF
        elif (valtype == 'QSizeF'):
            value = self.findSizeF('size')

        # Restore a QPoint
        elif (valtype == 'QPoint'):
            value = self.findPoint('point')

        # Restore a QPointF
        elif (valtype == 'QPointF'):
            value = self.findPointF('point')

        # Restore a QColor
        elif (valtype == 'QColor'):
            value = self.findColor('color')

        # restore a QFont
        elif (valtype == 'QFont'):
            value = QFont()
            value.fromString(self.attribute('value'))

        # Restore a string
        elif (valtype in ('str', 'unicode', 'QString')):
            value = unicode(self.attribute('value'))

        elif (valtype == 'ViewMode'):
            # If treated as a basic value would return fail
            value = int(self.attribute('value'))

        # Restore a QByteArray (Experimental)
        elif (valtype == 'QByteArray'):
            value = QByteArray.fromPercentEncoding(self.attribute('value', ''))

        # Restore a Qt.CheckState
        elif valtype == 'CheckState':
            value = Qt.CheckState(self.attribute('value', 0))

        # Restore a basic value
        else:
            try:
                value = eval('%s(%s)' % (valtype, self.attribute('value')))
            except:
                value = fail

        return value