本文整理匯總了Python中PyQt4.QtCore.QVariant方法的典型用法代碼示例。如果您正苦於以下問題:Python QtCore.QVariant方法的具體用法?Python QtCore.QVariant怎麽用?Python QtCore.QVariant使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt4.QtCore
的用法示例。
在下文中一共展示了QtCore.QVariant方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: readSettings
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def readSettings(self):
settings = QtCore.QSettings("Arabeyes.org", "Qutrub")
try:
family=settings.value("font_base_family", QtCore.QVariant(QString("Traditional Arabic"))).toString()
size,ok=settings.value("font_base_size", QtCore.QVariant(12)).toInt();
bold=settings.value("font_base_bold", QtCore.QVariant(True)).toBool()
dictsetting,ok=settings.value("DictSetting", QtCore.QVariant(1)).toInt();
except TypeError:
family=settings.value("font_base_family", "Traditional Arabic")
size=settings.value("font_base_size", "12")
size= int(size)
ok = bool(size)
bold=settings.value("font_base_bold", True)
bold = bool(bold)
dictsetting =settings.value("DictSetting", "1")
dictsetting = int(dictsetting)
if not ok:size=12;
self.font_result.setFamily(family)
self.font_result.setPointSize(size)
self.font_result.setBold(bold)
#read of dictsetting options
if not ok:dictsetting=1;
## self.BDictSetting.setCheckState(dictsetting);
示例2: from_qvariant
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def from_qvariant(qobj=None, convfunc=None):
"""Convert QVariant object to Python object
This is a transitional function from PyQt API #1 (QVariant exist)
to PyQt API #2 and Pyside (QVariant does not exist)"""
if PYQT_API_1:
# PyQt API #1
assert isinstance(convfunc, collections.Callable)
if convfunc in TEXT_TYPES or convfunc is to_text_string:
return convfunc(qobj.toString())
elif convfunc is bool:
return qobj.toBool()
elif convfunc is int:
return qobj.toInt()[0]
elif convfunc is float:
return qobj.toDouble()[0]
else:
return convfunc(qobj)
else:
# PyQt API #2
return qobj
示例3: readSettings
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def readSettings(self):
""" Load settings from previous session """
rospy.logdebug("Loading previous session settings")
settings = QSettings("omwdunkley", "reset" if self.options.reset else "flieROS"+str(self.options.radio) )
self.resize(settings.value("size", QVariant(QSize(300, 500))).toSize())
self.move(settings.value("pos", QVariant(QPoint(200, 200))).toPoint())
self.ui.checkBox_reconnect.setChecked(settings.value("autoReconnect", QVariant(self.ui.checkBox_reconnect.isChecked())).toBool())
self.ui.checkBox_beep.setChecked(settings.value("beepOn", QVariant(self.ui.checkBox_beep.isChecked())).toBool())
self.ui.checkBox_xmode.setChecked(settings.value("xmodeOn", QVariant(self.ui.checkBox_xmode.isChecked())).toBool())
self.ui.checkBox_kill.setChecked(settings.value("killOn", QVariant(self.ui.checkBox_kill.isChecked())).toBool())
self.ui.checkBox_startupConnect.setChecked(settings.value("startConnect", QVariant(self.ui.checkBox_startupConnect)).toBool())
self.ui.checkBox_pktHZ.setChecked(settings.value("pktHzOn", QVariant(self.ui.checkBox_pktHZ.isChecked())).toBool())
self.ui.checkBox_logHZ.setChecked(settings.value("logHzOn", QVariant(self.ui.checkBox_logHZ.isChecked())).toBool())
self.ui.horizontalSlider_pktHZ.setValue(settings.value("pktHzVal", QVariant(self.ui.horizontalSlider_pktHZ.value())).toInt()[0])
self.ui.horizontalSlider_logHZ.setValue(settings.value("logHzVal", QVariant(self.ui.horizontalSlider_logHZ.value())).toInt()[0])
self.ui.horizontalSlider_guiHZ.setValue(settings.value("guiHzVal", QVariant(self.ui.horizontalSlider_guiHZ.value())).toInt()[0])
self.ui.horizontalSlider_AI.setValue(settings.value("aiHzVal", QVariant(self.ui.horizontalSlider_AI.value())).toInt()[0])
self.logManager.header().restoreState(settings.value("logTreeH", self.logManager.header().saveState()).toByteArray())
self.paramManager.header().restoreState(settings.value("paramTreeH", self.paramManager.header().saveState()).toByteArray())
示例4: writeSettings
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def writeSettings(self):
""" Write settings to load at next start up """
rospy.logdebug("Saving session settings")
settings = QSettings("omwdunkley", "flieROS"+str(self.options.radio))
settings.setValue("pos", QVariant(self.pos()))
settings.setValue("size", QVariant(self.size()))
settings.setValue("autoReconnect", QVariant(self.ui.checkBox_reconnect.isChecked()))
settings.setValue("beepOn", QVariant(self.ui.checkBox_beep.isChecked()))
settings.setValue("xmodeOn", QVariant(self.ui.checkBox_xmode.isChecked()))
settings.setValue("killOn", QVariant(self.ui.checkBox_kill.isChecked()))
settings.setValue("startConnect", QVariant(self.ui.checkBox_startupConnect.isChecked()))
settings.setValue("pktHzOn", QVariant(self.ui.checkBox_pktHZ.isChecked()))
settings.setValue("logHzOn", QVariant(self.ui.checkBox_logHZ.isChecked()))
settings.setValue("pktHzVal", QVariant(self.ui.horizontalSlider_pktHZ.value()))
settings.setValue("logHzVal", QVariant(self.ui.horizontalSlider_logHZ.value()))
settings.setValue("guiHzVal", QVariant(self.ui.horizontalSlider_guiHZ.value()))
settings.setValue("aiHzVal", QVariant(self.ui.horizontalSlider_AI.value()))
settings.setValue("logTreeH",QVariant(self.logManager.header().saveState()))
settings.setValue("paramTreeH",QVariant(self.paramManager.header().saveState()))
示例5: flags
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def flags(self, index):
if not index.isValid():
return 0
# Prevent groups from selection
if not index.internalPointer().obj:
return Qt.Qt.ItemIsEnabled
else:
return Qt.Qt.ItemIsEnabled | Qt.Qt.ItemIsSelectable | Qt.Qt.ItemIsEditable
return QtCore.QAbstractItemModel.flags(self, index)
# def data(self, index, role=Qt.Qt.DisplayRole):
# if not index.isValid() or not 0 <= index.row() < self.rowCount():
# return QtCore.QVariant()
# row = index.row()
# if role == Qt.Qt.DisplayRole:
# return self.object_list[row].options["name"]
# if role == Qt.Qt.DecorationRole:
# return self.icons[self.object_list[row].kind]
# # if role == Qt.Qt.CheckStateRole:
# # if row in self.checked_indexes:
# # return Qt.Qt.Checked
# # else:
# # return Qt.Qt.Unchecked
示例6: headerData
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def headerData(self, section, orientation, role = QtCore.Qt.DisplayRole):
if orientation == QtCore.Qt.Vertical:
return QtCore.QVariant(None)
data = None
if section == 0:
if role == QtCore.Qt.DisplayRole:
data = 'Key'
elif role == QtCore.Qt.ToolTipRole:
data = 'Variable name'
elif section == 1:
if role == QtCore.Qt.DisplayRole:
data = 'Value'
elif role == QtCore.Qt.ToolTipRole:
data = 'Variable value'
return QtCore.QVariant(data)
示例7: data
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def data(self, index, role = QtCore.Qt.DisplayRole):
if role not in [QtCore.Qt.DisplayRole, QtCore.Qt.UserRole]:
return QtCore.QVariant(None)
data = None
r = index.row()
c = index.column()
key = self.vars_data.keys()[r]
if c == 0:
data = key
elif c == 1:
if role == QtCore.Qt.DisplayRole:
data = self.vars_data[key]
elif role == QtCore.Qt.UserRole:
value = self.vars_data[key]
cached = self.classification_cache.get(value, None)
if cached is None:
data = classify_data(value)
self.classification_cache[value] = data
else:
data = cached
return QtCore.QVariant(data)
示例8: set_fields
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def set_fields(self, script=None, txTo=None, inIdx=None, hashType=None):
"""Populate model.
Args:
script (str): Human-readable script.
txTo (Transaction): Transaction.
inIdx (int): Input index.
hashType (int): SigHash type.
"""
if script is not None:
self.setData(self.index(0, 0), QVariant(script))
if txTo is not None:
self.setData(self.index(0, 1), QVariant(b2x(txTo.serialize())))
if inIdx is not None:
self.setData(self.index(0, 2), QVariant(inIdx))
if hashType is not None:
self.setData(self.index(0, 3), QVariant(hashType & 0x1f), RawRole)
self.setData(self.index(0, 4), QVariant(hashType & SIGHASH_ANYONECANPAY))
示例9: readSettings
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def readSettings(self):
settings = QtCore.QSettings("Arabeyes.org", "Qutrub")
try:
family=settings.value("font_base_family", QtCore.QVariant(QString("Traditional Arabic"))).toString()
except TypeError:
family = str(settings.value("font_base_family", "Traditional Arabic"))
try:
size,ok=settings.value("font_base_size", QtCore.QVariant(12)).toInt();
except TypeError:
size = settings.value("font_base_size", 12)
size = int(size)
ok = bool(size)
if not ok:size=12;
try:
bold=settings.value("font_base_bold", QtCore.QVariant(True)).toBool()
except TypeError:
bold= bool(settings.value("font_base_bold", True))
self.font_result.setFamily(family)
self.font_result.setPointSize(size)
self.font_result.setBold(bold)
#read of dictsetting options
try:
dictsetting,ok = settings.value("DictSetting", QtCore.QVariant(1)).toInt();
except TypeError:
dictsetting = settings.value("DictSetting", 1);
ok = bool(dictsetting)
if not ok:dictsetting=1;
self.BDictOption=dictsetting;
示例10: writeSettings
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def writeSettings(self):
settings = QtCore.QSettings("Arabeyes.org", "Qutrub")
try:
settings.setValue("font_base_family", QtCore.QVariant(self.font_result.family()))
settings.setValue("font_base_size", QtCore.QVariant(self.font_result.pointSize()))
settings.setValue("font_base_bold", QtCore.QVariant(self.font_result.bold()))
except:
settings.setValue("font_base_family", self.font_result.family())
settings.setValue("font_base_size", self.font_result.pointSize())
settings.setValue("font_base_bold", self.font_result.bold())
#write of dictsetting options
## settings.setValue("DictSetting", QtCore.QVariant(self.BDictSetting.checkState()));
示例11: to_qvariant
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def to_qvariant(pyobj=None):
"""Convert Python object to QVariant
This is a transitional function from PyQt API #1 (QVariant exist)
to PyQt API #2 and Pyside (QVariant does not exist)"""
if PYQT_API_1:
# PyQt API #1
from PyQt4.QtCore import QVariant
return QVariant(pyobj)
else:
# PyQt API #2
return pyobj
示例12: headerData
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def headerData(self, section, orientation, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
return QVariant()
if orientation == Qt.Horizontal:
try:
return self.df.columns.tolist()[section]
except (IndexError, ):
return QVariant()
elif orientation == Qt.Vertical:
try:
# return self.df.index.tolist()
return self.df.index.tolist()[section]
except (IndexError, ):
return QVariant()
示例13: data
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def data(self, index, role=Qt.DisplayRole):
if role != Qt.DisplayRole:
return QVariant()
if not index.isValid():
return QVariant()
return QVariant(str(self.df.ix[index.row(), index.column()]))
示例14: setData
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def setData(self, index, value, role):
row = self.df.index[index.row()]
col = self.df.columns[index.column()]
if hasattr(value, 'toPyObject'):
# PyQt4 gets a QVariant
value = value.toPyObject()
else:
# PySide gets an unicode
dtype = self.df[col].dtype
if dtype != object:
value = None if value == '' else dtype.type(value)
self.df.set_value(row, col, value)
return True
示例15: __init__
# 需要導入模塊: from PyQt4 import QtCore [as 別名]
# 或者: from PyQt4.QtCore import QVariant [as 別名]
def __init__(self, parent, name, children, hz=50):
super(LogGroup, self).__init__(parent)
self.name = name
self.setFlags(self.flags() | Qt.ItemIsEditable | Qt.ItemIsUserCheckable)
# Keep track of if all/none of the children are active
self.cAll = True
self.cNone = True
self.validHZ = list(OrderedDict.fromkeys([round(100/floor(100/x),2) for x in range(1,100)]))
self.hzTarget = hz
# Monitor the incoming frequency
self.fm = None
self.fmOn = True
# log config
self.lg = None
# Show text
QtGui.QTreeWidgetItem.setData(self, 0, Qt.DisplayRole, QVariant(name))
QtGui.QTreeWidgetItem.setData(self, 0, Qt.CheckStateRole, Qt.Unchecked)
QtGui.QTreeWidgetItem.setData(self, 1, Qt.DisplayRole, "Off")
QtGui.QTreeWidgetItem.setData(self, 3, Qt.DisplayRole, QVariant(0))
#QtGui.QTreeWidgetItem.setData(self, 4, Qt.CheckStateRole, Qt.Unchecked)
self.readSettings()
# Initialise Children
for c in sorted(children.keys()):
self.addChild(LogItem(self, children[c]))
self.c = 0
# Now everything is initialised except the logging
# Start logging if active
if self.checkState(0) == Qt.Checked:
self.requestLog()