我正在尝试使用Qt Designer和pyside-uic mydesign.ui> design.py
但是,这个程序不存在.我查看了python 2.7下的站点包,我看到:pyside-lupdate.exe pyside-rcc.exe
和一堆其他程序,但没有像pyside-uic.exe这样的东西......为什么?为什么安装包中缺少它?我从哪里得到它?
我正在使用带有Qt集成的Eclipse的PyDev插件.我安装了PySide,我遇到了SVG图像格式的问题.我知道当我运行我的应用程序时,C:\Python27\Lib\site-packages\PySide\plugins\imageformats找到了位于的格式.除了SVG格式之外的所有格式.我可以删除qico4.dll,它不再找到它们并将其重新放入并再次找到它们.
我在我的代码中使用这一行: plugs = QtGui.QImageReader.supportedImageFormats()
它从qsvg4.dll找到除SVG格式以外的所有格式?为什么会这样?我搜索,搜索和搜索,似乎无法找出原因.格式是否应以支持的图像格式显示?使用SVG图像需要做些什么吗?我可以使用.ico文件很好,需要qico4.dll并位于同一个地方,这就是为什么我不明白问题是什么?任何帮助表示赞赏!
下面的代码应该打印三次相同的东西.为什么不呢?
from PySide.QtCore import QObject
class A(QObject):
instance = 1
@classmethod
def test(cls):
cls.instance # Remove this line and it prints the right thing
cls.instance = cls()
print(cls.__dict__['instance'])
print(cls.instance)
print(type.__getattribute__(cls, 'instance'))
A.test()
Run Code Online (Sandbox Code Playgroud)
预期结果:
<__main__.A object at 0x1310c20>
<__main__.A object at 0x1310c20>
<__main__.A object at 0x1310c20>
Run Code Online (Sandbox Code Playgroud)
实际结果:
<__main__.A object at 0x2242878>
1
1
Run Code Online (Sandbox Code Playgroud)
QObject背后的元类甚至不会覆盖getattribute,那么我怎么可能没有使用"cls.instance"获取A实例?
更奇怪的是,在分配属性之前不访问该属性(请参阅注释的代码行)使其工作正常.
我可以重现如下(使用PySide 1.1.0):
我正在尝试在PyQt中创建一个可编辑的表.这是仅显示表格的代码:
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import *
from PyQt4.QtGui import *
# données à représenter
my_array = [['00','01','02'],
['10','11','12'],
['20','21','22']]
def main():
app = QApplication(sys.argv)
w = MyWindow()
w.show()
sys.exit(app.exec_())
# création de la vue et du conteneur
class MyWindow(QWidget):
def __init__(self, *args):
QWidget.__init__(self, *args)
tablemodel = MyTableModel(my_array, self)
tableview = QTableView()
tableview.setModel(tablemodel)
layout = QVBoxLayout(self)
layout.addWidget(tableview)
self.setLayout(layout)
# création du modèle
class MyTableModel(QAbstractTableModel):
def __init__(self, datain, parent = None, *args):
QAbstractTableModel.__init__(self, parent, *args)
self.arraydata …Run Code Online (Sandbox Code Playgroud) 我有一些困难QGraphicsView和QGraphicsScene.当我在场景中缩放/取消缩放并使用mousePressEvent创建项目时,我的位置有一个偏移量.如何避免这种情况?
event.pos() 似乎是问题..
from PyQt4 import QtCore, QtGui
class graphicsItem (QtGui.QGraphicsItem):
def __init__ (self):
super(graphicsItem, self).__init__()
self.rectF = QtCore.QRectF(0,0,10,10)
def boundingRect (self):
return self.rectF
def paint (self, painter=None, style=None, widget=None):
painter.fillRect(self.rectF, QtCore.Qt.red)
class graphicsScene (QtGui.QGraphicsScene):
def __init__ (self, parent=None):
super (graphicsScene, self).__init__ (parent)
class graphicsView (QtGui.QGraphicsView):
def __init__ (self, parent = None):
super (graphicsView, self).__init__ (parent)
self.parent = parent
def mousePressEvent(self, event):
super (graphicsView, self).mousePressEvent(event)
item = graphicsItem()
position = QtCore.QPointF(event.pos()) - item.rectF.center()
item.setPos(position.x() , position.y()) …Run Code Online (Sandbox Code Playgroud) 我是Qt(PyQt - PySide)的新手.
我正在尝试构建一个自定义小部件,这是一个菜单.然而,我走上了艰难的道路,似乎无法将自己排除在外.我已经阅读了文档,但我认为没有鼠标状态我可以验证以确定鼠标光标是否在给定的小部件上.
我呼吁函数mouseReleaseEvent的QWidget.
例:
def mouseReleaseEvent(self, e):
Run Code Online (Sandbox Code Playgroud)
触发此事件时,我必须知道鼠标实际上是在窗口小部件上还是在窗口外部(触发此事件的窗口小部件).
if mouseCursorOverSelf == True:
# do something ..
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?我需要做什么?
非常感谢你!
有没有办法从代码中为QTreeWidget设置列宽?我想chage第一列的默认宽度.我正在使用PySide.
我有一个像这样的QML textInput元素:
TextBox.qml
FocusScope {
id: focusScope
property int fontSize: focusScope.height -30
property int textBoxWidth: parent.width * 0.8
property int textBoxHeight: 45
property string placeHolder: 'Type something...'
property bool isUserInTheMiddleOfEntringText: false
width: textBoxWidth
height: textBoxHeight
Rectangle {
width: parent.width
height: parent.height
border.color:'blue'
border.width: 3
radius: 0
MouseArea {
anchors.fill: parent
onClicked: {
focusScope.focus = true
textInput.openSoftwareInputPanel()
}
}
}
Text {
id: typeSomething
anchors.fill: parent; anchors.rightMargin: 8
verticalAlignment: Text.AlignVCenter
text: placeHolder
color: 'red'
font.italic: true
font.pointSize: fontSize
MouseArea {
anchors.fill: …Run Code Online (Sandbox Code Playgroud) 我想在CentOS上安装ReText.有一个问题,
[root@localhost scripts-2.6]# python retext.py
Traceback (most recent call last):
File "retext.py", line 23, in <module>
from ReText import QtCore, QtWidgets, QtWebKit, datadirs, globalSettings
File "/usr/lib/python2.6/site-packages/ReText/__init__.py", line 21, in <module>
from PySide import QtCore, QtGui, QtWebKit
ImportError: No module named PySide
Run Code Online (Sandbox Code Playgroud)
然后我键入yum install PySide并yum install python-pyside安装PySide,并收到消息No package available.
我也试过yum search pyside和yum search python-,但没有找到PySide包.
pyside ×10
qt ×7
python ×6
pyqt ×4
c++ ×2
autocomplete ×1
centos ×1
image ×1
installation ×1
pyqt4 ×1
python-3.x ×1
qml ×1
qt4 ×1
qtreewidget ×1
qwidget ×1
svg ×1
yum ×1