pyqt

how can I clear a pyqt QTableWidget?

痴心易碎 提交于 2020-12-25 01:04:17
问题 I want to clear my QTableWidget. First of all I select a user in a qcombobox after that I click a qpushbutton and I populate it from database records; when I select other user and I click the qpushbutton to add data I try to clear with: self.tableFriends.clear() The data disappears but the rows remain. The code I populate with is: def getFriends(self): id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject() rowIndex = 0 self.tableFriends.clear() for row in self.SELECT_FRIENDS(id

PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox增加自定义按钮的方法

血红的双手。 提交于 2020-12-24 09:05:22
在Qt Designer中可以预先定义标准按钮,相关支持的标准按钮请见《 PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox的StandardButtons标准按钮 》。 除了标准按钮,QDialogButtonBox允许增加自定义按钮。如果要在标准按钮之外增加自定义按钮,可以使用addButton方法。 案例 在Qt Designer中定义了一个名为buttonBox的QDialogButtonBox,在其下选择定义了所有标准按钮,如图: 该界面生成代码的模块为mainWinTest,对应的界面类为mainWinTest,从界面类派生类为Ui_mainWindowWin,其类定义及构造方法如下: class Ui_mainWindowWin ( QtWidgets . QMainWindow , mainWinTest . Ui_MainWindow ) : def __init__ ( self ) : super ( Ui_mainWindowWin , self ) . __init__ ( ) self . setupUi ( self ) self . buttonBox . addButton ( "关闭" , QDialogButtonBox . DestructiveRole ) #增加自定义按钮

how to use QGraphicsView::RubberBandDrag?

戏子无情 提交于 2020-12-23 11:53:28
问题 Can somebody please provide an explanation, or better yet a short example, of how to use the RubberBandDrag enum value in QGraphicsView ? PyQt5 would be great, but I can translate from the C++ version if that is preferred for whomever can provide a helpful exmaple. NoDrag and ScrollHandDrag are relatively easy to understand ( NoDrag makes the mouse a pointer and you can capture clicks at certain locations, ScrollHandDrag makes the mouse a hand and you can implement click and drag to scroll

how to use QGraphicsView::RubberBandDrag?

徘徊边缘 提交于 2020-12-23 11:52:34
问题 Can somebody please provide an explanation, or better yet a short example, of how to use the RubberBandDrag enum value in QGraphicsView ? PyQt5 would be great, but I can translate from the C++ version if that is preferred for whomever can provide a helpful exmaple. NoDrag and ScrollHandDrag are relatively easy to understand ( NoDrag makes the mouse a pointer and you can capture clicks at certain locations, ScrollHandDrag makes the mouse a hand and you can implement click and drag to scroll

setPixmap crashing when trying to show image in label

一笑奈何 提交于 2020-12-21 04:05:26
问题 I have created a minimal example with pyqt designer, that changes the text of a label when a button is pressed and is supposed to present a screenshot in the window, via the label. Unfortunately, the example just crashes when it tries to show the screenshot in the label. from PIL.ImageQt import ImageQt from PyQt5 import QtCore, QtGui, QtWidgets from pyscreenshot import grab class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(503, 382) self.pushButton =

setPixmap crashing when trying to show image in label

廉价感情. 提交于 2020-12-21 04:03:06
问题 I have created a minimal example with pyqt designer, that changes the text of a label when a button is pressed and is supposed to present a screenshot in the window, via the label. Unfortunately, the example just crashes when it tries to show the screenshot in the label. from PIL.ImageQt import ImageQt from PyQt5 import QtCore, QtGui, QtWidgets from pyscreenshot import grab class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(503, 382) self.pushButton =

setPixmap crashing when trying to show image in label

霸气de小男生 提交于 2020-12-21 04:03:01
问题 I have created a minimal example with pyqt designer, that changes the text of a label when a button is pressed and is supposed to present a screenshot in the window, via the label. Unfortunately, the example just crashes when it tries to show the screenshot in the label. from PIL.ImageQt import ImageQt from PyQt5 import QtCore, QtGui, QtWidgets from pyscreenshot import grab class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(503, 382) self.pushButton =

vs2015 cmd.exe已退出 代码为1

不想你离开。 提交于 2020-12-19 09:00:39
https://blog.csdn.net/changbin91/article/details/42874377?utm_source=blogxgwz0 https://blog.csdn.net/shile/article/details/51198482 MSB6006 “cmd.exe”已退出,代码为 1 https://blog.csdn.net/u012043391/article/details/74910831 from PyQt5.QtCore import PYQT_VERSION_STR, QDir, QFile ImportError: DLL load failed: The specified module could not be found. File "C:\OSGeo4W64\apps\Python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\OSGeo4W64\apps\Python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\OSGeo4W64\apps\Python36\lib\site-packages\PyQt5

少造轮子!推荐一个Qt的Python组件库

血红的双手。 提交于 2020-12-18 06:32:20
虽然Qt提供了不少现成的组件,但是在Python中使用PyQt5或PySide2进行图形界面程序开发的过程,还是免不了要根据自己的需求组合一些小部件以形成新的自定义组件。 最近州的先生在写一个桌面图形界面的登录密码框的过程中,发现了这样一个小巧的自定义组件库。 其目前提供了密码输入框组件、渐变组件、均衡器组件、调色板组件。 下面我们一起来看看它的效果。 安装 直接使用 pip 工具进行安装即可,命令如下: pip install qtwidgets 密码输入框 在PyQt5和PySide2中,我们一般使用QLineEdit()小部件,通过设置它的 EchoMode 属性来让输入的文本显示星号而非明文,代码如下所示: # encoding:utf-8 from PySide2 import QtWidgets import sys class Widget ( QtWidgets . QWidget ): def __init__ ( self ): super (). __init__ () self . setWindowTitle ( "州的先生-zmister.com" ) self . pwd_input = QtWidgets . QLineEdit ( self ) self . pwd_input . setEchoMode ( QtWidgets .

“Blinking” buttons in PyQT5

蹲街弑〆低调 提交于 2020-12-15 10:24:36
问题 Here's the deal: I'm trying to make button A "blink" when button B is pushed, and the blinking should then stop when the user pushes button A. Furthermore, button A should then go back to its former state. After long reading through the documentation and other questions at SO, I have now following piece of code: Python 2.7 class Widget(QWidget): def __init__(self): super(Widget, self).__init__() self.resize(300,200) layout = QVBoxLayout(self) self.button_stop = QPushButton("Stop") layout