當前位置: 首頁>>代碼示例>>Python>>正文


Python QtCore.QVariant方法代碼示例

本文整理匯總了Python中PyQt5.QtCore.QVariant方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QVariant方法的具體用法?Python QtCore.QVariant怎麽用?Python QtCore.QVariant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt5.QtCore的用法示例。


在下文中一共展示了QtCore.QVariant方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setData

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def setData(self, index, value, role = Qt.EditRole):
        if not index.isValid():
            return False
        obj = self.getObject(index)
        prop = self.getProperty(index)
        if (obj is None) or (prop is None):
            return None
        try:
            action = prop.get('action', None)
            if action is not None:
                if action == "button":
                    getAttrRecursive(obj, prop['attr'])()  # Call obj.attr()
                    return True
                elif action == "fileDialog":
                    pass  # File loading handled via @property.setter obj.attr below. Otherwise just sets the file name text.
            if role == Qt.EditRole:
                if type(value) == QVariant:
                    value = value.toPyObject()
                if (QT_VERSION_STR[0] == '4') and (type(value) == QString):
                    value = str(value)
                setAttrRecursive(obj, prop['attr'], value)
                return True
        except:
            return False
        return False 
開發者ID:aseylys,項目名稱:KStock,代碼行數:27,代碼來源:ObjList.py

示例2: displayText

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def displayText(self, value, locale):
        ''' 
        Show str rep of current choice (or choice key if choice is a (key, value) tuple).
        '''
        try:
            if type(value) == QVariant:
                value = value.toPyObject()  # QVariant ==> object
            for choice in self.choices:
                if (type(choice) is tuple) and (len(choice) == 2):
                    # choice is a (key, value) tuple.
                    # Display the key, not the value.
                    key, val = choice
                    if val == value:
                        return str(key)
                else:
                    # choice is a value.
                    # Display it's str rep.
                    if choice == value:
                        return str(choice)
            # If value is not in our list of choices, show str rep of value.
            return str(value)
        except:
            return "" 
開發者ID:aseylys,項目名稱:KStock,代碼行數:25,代碼來源:ComboBoxDelegateQt.py

示例3: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role=None):
        if index.isValid():
            data = index.internalPointer()
            col = index.column()
            if data:
                if role in (Qt.DisplayRole, Qt.EditRole):
                    if col == 0:
                        # if isinstance(data, Bip44AccountType):
                        #     return data.get_account_name()
                        # else:
                        #     return f'/{data.address_index}: {data.address}'
                        return data
                    elif col == 1:
                        b = data.balance
                        if b:
                            b = b/1e8
                        return b
                    elif col == 2:
                        b = data.received
                        if b:
                            b = b/1e8
                        return b
        return QVariant() 
開發者ID:Bertrand256,項目名稱:dash-masternode-tool,代碼行數:25,代碼來源:wallet_data_models.py

示例4: closeEvent

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def closeEvent(self, event=None):
        if self.okToContinue():
            for tab in range(self.centralwidget.count()):
                centralwidget = self.centralwidget.widget(tab)
                scene = centralwidget.subWindowList()[0].widget().scene()
                scene.clearSelection()
            settings = QtCore.QSettings()
            if self.filename:
                filename = QtCore.QVariant(self.filename)
            else:
                filename = QtCore.QVariant()
            settings.setValue("LastFile", filename)
            if self.recentFiles:
                recentFiles = QtCore.QVariant(self.recentFiles)
            else:
                recentFiles = QtCore.QVariant()
            settings.setValue("RecentFiles", recentFiles)
            settings.setValue("Geometry", QtCore.QVariant(self.saveGeometry()))
            settings.setValue("MainWindow/State",
                              QtCore.QVariant(self.saveState()))
            self.close()
        else:
            event.ignore() 
開發者ID:jjgomera,項目名稱:pychemqt,代碼行數:25,代碼來源:mainWindow.py

示例5: aboutToShow_MenuRecentFiles

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def aboutToShow_MenuRecentFiles(self):
        self.menuRecentFiles.clear()
        recentFiles = []
        for fname in self.recentFiles:
            if fname not in self.filename and QtCore.QFile.exists(fname):
                recentFiles.append(fname)
        if recentFiles:
            self.menuRecentFiles.addSeparator()
            for i, fname in enumerate(recentFiles):
                action = QtWidgets.QAction("&%d %s" % (i + 1, fname), self)
                action.setData(QtCore.QVariant(fname))
                action.triggered.connect(self.loadFile)
                self.menuRecentFiles.addAction(action)
        self.menuRecentFiles.addSeparator()
        self.menuRecentFiles.addAction(
            QtGui.QIcon(IMAGE_PATH + "button/clear.png"),
            QtWidgets.QApplication.translate("pychemqt", "Clear"),
            self.clearRecentFiles)

# File Manipulation 
開發者ID:jjgomera,項目名稱:pychemqt,代碼行數:22,代碼來源:mainWindow.py

示例6: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role):
        if not self._container:
            return QVariant()

        if not index.isValid():
            return QVariant()

        if role not in self._role_names:
            return QVariant()

        role_name = self._role_names[role]
        definition = index.internalPointer()

        try:
            data = getattr(definition, role_name.decode())
        except AttributeError:
            data = ""

        return QVariant(str(data)) 
開發者ID:Ultimaker,項目名稱:Uranium,代碼行數:21,代碼來源:DefinitionTreeModel.py

示例7: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role):
        if not index.isValid():
            return None

        item = index.internalPointer()

        if role == Qt.ForegroundRole:
            if item.itemData[1] == 'removed':
                return QVariant(QColor(Qt.red))
            elif item.itemData[1] == 'added':
                return QVariant(QColor(Qt.green))
            elif item.itemData[1] == 'modified' or item.itemData[1].startswith('['):
                return QVariant(QColor(Qt.darkYellow))

        if role == Qt.DisplayRole:
            return item.data(index.column())
        else:
            return None 
開發者ID:borgbase,項目名稱:vorta,代碼行數:20,代碼來源:diff_result.py

示例8: completerModel

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def completerModel(self) -> QVariant:
        return QVariant(
            [
                dict(
                    identifier='.IFJcode17',
                    type=Expression.ExpressionTypes.Header
                )
            ] if '.IFJcode17' not in self.code else [] + [
                dict(
                    identifier=match,
                    type=Expression.ExpressionTypes.Types
                ) for match in sorted(("int", "bool", "float", "string"))
            ] + [
                dict(
                    identifier=func,
                    type=Expression.ExpressionTypes.Instruction
                ) for func in INSTRUCTIONS
            ] + [
                dict(
                    identifier=match,
                    type=Expression.ExpressionTypes.Variable
                ) for match in sorted(set(self.VARIABLE_RE.findall(self._code)))
            ]
        ) 
開發者ID:thejoeejoee,項目名稱:VUT-FIT-IFJ-2017-toolkit,代碼行數:26,代碼來源:code_analyzer.py

示例9: compare

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def compare(self, new_code: str) -> QVariant:
        diff_lines = []
        hunk = []

        diff = list(unified_diff(self._code.splitlines(True), new_code.splitlines(True)))[2::]
        temp_code_diff = list(unified_diff(self._temp_code.splitlines(True), new_code.splitlines(True)))[2::]

        for line in diff:
            hunk_info_match = re.match(r'@@ -\d+,?\d* \+\d+,?\d* @@', line)
            if hunk_info_match is not None:
                diff_lines.extend(self._get_modified_lines(hunk))
                hunk = []
            hunk.append(line)

        if hunk:
            diff_lines.extend(self._get_modified_lines(hunk))

        added_lines, removed_lines = self._get_lines_diffs(new_code)

        if added_lines:
            self.addedLines.emit(QVariant(added_lines))
        if removed_lines:
            self.removedLines.emit(QVariant(removed_lines))

        return QVariant(diff_lines) 
開發者ID:thejoeejoee,項目名稱:VUT-FIT-IFJ-2017-toolkit,代碼行數:27,代碼來源:diff_code_analyzer.py

示例10: setScale

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def setScale(self, scale):
        self.group_box.setMaximumWidth(int(340 * scale))
        self.label['actualfreq'].setMinimumWidth(int(100 * scale))
        self.label['actualfreq'].setMinimumWidth(int(100 * scale))
        self.label['returnloss'].setMinimumWidth(int(80 * scale))
        if self.coloredText:
            color_string = QtCore.QVariant(self.color)
            color_string.convert(QtCore.QVariant.String)
            self.group_box.setStyleSheet(
                f"QGroupBox {{ color: {color_string.value()}; "
                f"font-size: {self._size_str()}}};"
            )
        else:
            self.group_box.setStyleSheet(
                f"QGroupBox {{ font-size: {self._size_str()}}};"
            ) 
開發者ID:NanoVNA-Saver,項目名稱:nanovna-saver,代碼行數:18,代碼來源:Widget.py

示例11: setColor

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def setColor(self, color):
        if color.isValid():
            self.color = color
            p = self.btnColorPicker.palette()
            p.setColor(QtGui.QPalette.ButtonText, self.color)
            self.btnColorPicker.setPalette(p)
        if self.coloredText:
            color_string = QtCore.QVariant(color)
            color_string.convert(QtCore.QVariant.String)
            self.group_box.setStyleSheet(
                f"QGroupBox {{ color: {color_string.value()}; "
                f"font-size: {self._size_str()}}};"
            )
        else:
            self.group_box.setStyleSheet(
                f"QGroupBox {{ font-size: {self._size_str()}}};"
            ) 
開發者ID:NanoVNA-Saver,項目名稱:nanovna-saver,代碼行數:19,代碼來源:Widget.py

示例12: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role):
        if index.isValid() or (0 <= index.row() < len(self.ListItemData)):
            if role == Qt.DisplayRole:
                return QVariant(self.ListItemData[index.row()]['name'])
            elif role == Qt.DecorationRole:
                return QVariant(QIcon(self.ListItemData[index.row()]['iconPath']))
            elif role == Qt.SizeHintRole:
                return QVariant(QSize(70,80))
            elif role == Qt.TextAlignmentRole:
                return QVariant(int(Qt.AlignHCenter|Qt.AlignVCenter))
            elif role == Qt.FontRole:
                font = QFont()
                font.setPixelSize(20)
                return QVariant(font)
        else:            
            return QVariant() 
開發者ID:Python3Spiders,項目名稱:WeiboSuperSpider,代碼行數:18,代碼來源:ListModel.py

示例13: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, rola=Qt.DisplayRole):
        """ Wyświetlanie danych """
        i = index.row()
        j = index.column()

        if rola == Qt.DisplayRole:
            return '{0}'.format(self.tabela[i][j])
        elif rola == Qt.CheckStateRole and (j == 3 or j == 4):
            if self.tabela[i][j]:
                return Qt.Checked
            else:
                return Qt.Unchecked
        elif rola == Qt.EditRole and j == 1:
            return self.tabela[i][j]
        else:
            return QVariant() 
開發者ID:koduj-z-klasa,項目名稱:python101,代碼行數:18,代碼來源:tabmodel_z5.py

示例14: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role=None):
        value = self._anchor_positions[index.row()][index.column()]
        if index.isValid():
            if index.column() == 0:
                if role == Qt.CheckStateRole:
                    return QVariant(value)
            elif index.column() == 1:
                if role == Qt.DisplayRole:
                    return QVariant(value)
            else:
                if role == Qt.DisplayRole:
                    return QVariant('%.2f' % (value))
                elif role == Qt.EditRole:
                    return QVariant(value)
                elif role == Qt.BackgroundRole:
                    return self._get_background(index.row(), index.column())

        return QVariant() 
開發者ID:bitcraze,項目名稱:crazyflie-clients-python,代碼行數:20,代碼來源:anchor_position_dialog.py

示例15: data

# 需要導入模塊: from PyQt5 import QtCore [as 別名]
# 或者: from PyQt5.QtCore import QVariant [as 別名]
def data(self, index, role=QtCore.Qt.DisplayRole):
        if index.isValid():
            if(role==QtCore.Qt.DisplayRole):
                return self._data.values[index.row()][index.column()]
            else:
                # self._roleName 은 QHash(int, QByteArray)
                columnName = self._roleNames[role].data().decode('utf8')
                print('row {} col {} role {} columnName {} '.format(index.row(), index.column(), role, columnName))
                print(self._data.at[index.row(), columnName])
                return self._data.at[index.row(), columnName]
        return QVariant() 
開發者ID:coreanq,項目名稱:kw_condition,代碼行數:13,代碼來源:pandasmodel.py


注:本文中的PyQt5.QtCore.QVariant方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。