pyqt

七、PyQT5控件——QSlider,QSpinBox

浪尽此生 提交于 2021-01-14 11:02:04
一、Qslider QSlider是一个滑动条,可以设置成水平或垂直放置。最常用的方法允许用户在某一范围内互动该滑块,并将滑块的位置转换成一个整数值(int类型),这种方式可以在某一个范围内平顺的变动,并触发valuechangd信号,产生相应变化。但QSlider能发射的信号并不局限于这一种: valuechanged。滑块位置变动时发射此信号; sliderPressed。当用户按下滑块时就会发射该信号; sliderMoved。当用户拖动滑块时发射信号; sliderReleased。用户释放滑块时发射该信号。 1 import sys,os 2 from PyQt5.QtWidgets import QWidget,QSlider,QApplication,QLabel,QVBoxLayout 3 from PyQt5.QtGui import QIcon 4 from PyQt5.QtCore import Qt 5 6 path = os.path.dirname(os.path.dirname(os.path.dirname( __file__ ))) 7 8 class MyWindow(QWidget): 9 10 def __init__ (self): 11 super(). __init__ () 12 self.initUI() 13 14 def

【转】PyQt5系列教程(七)控件

∥☆過路亽.° 提交于 2021-01-14 10:14:58
PyQt5系列教程(七)控件 软硬件环境 Windows 10 Python 3.4.2 PyQt 5.5.1 PyCharm 5.0.4 前言 控件是PyQt应用程序的基石。PyQt5自带很多不同的控件,包括像button、check box、slider等等。在本节中我们将学习几个非常有用的控件:QCheckBox、ToggleButton、QSlider、QProgressBar和QCalendarWidget。 QCheckBox 一个QCheckBox会有2种状态:选中和为选中。它有一个选择框和一个label组成,它常常被用来表示应用的某些特性是可启用或不启用的。 # -*- coding: utf-8 -*- __author__ = 'djstava@gmail.com' """ ZetCode PyQt5 tutorial In this example, a QCheckBox widget is used to toggle the title of a window. author: Jan Bodnar website: zetcode.com last edited: January 2015 """ import sys from PyQt5.QtWidgets import QWidget, QCheckBox, QApplication from

Stylesheet does not work properly in PyQt

情到浓时终转凉″ 提交于 2021-01-07 02:54:23
问题 I am trying to build an app using PyQt, so I decided to first develop the UI using qt Designer. I want to style my elements, so I am using stylesheets to specify the styles I need. After making the UI in qt Designer, I used the preview button to see if everything works, and everything was working as expected. Then, I used pyuic5 to convert the UI file to the python version. Now, almost everything is OK, but SOME stylesheets do not work properly. For example, I used stylesheet for QComboBox,

Stylesheet does not work properly in PyQt

浪尽此生 提交于 2021-01-07 02:53:38
问题 I am trying to build an app using PyQt, so I decided to first develop the UI using qt Designer. I want to style my elements, so I am using stylesheets to specify the styles I need. After making the UI in qt Designer, I used the preview button to see if everything works, and everything was working as expected. Then, I used pyuic5 to convert the UI file to the python version. Now, almost everything is OK, but SOME stylesheets do not work properly. For example, I used stylesheet for QComboBox,

how to reorder QListView items when the model is QSqlTableModel with drag and drop?

爱⌒轻易说出口 提交于 2021-01-07 02:52:56
问题 i'm working with @eyllanesc answer example and i want to reorder the items i followed many answers in stackoverflow and the qt documentation but i'm not able to make it work, it seems like very hard to reorder items with dragging and droping them. i did it with QListWidget but not with QListView here is my code : import sys from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtSql import * import sys, os def create_connection(): db = QSqlDatabase

ubuntu16.04 install qtcreator

一曲冷凌霜 提交于 2021-01-05 22:19:08
1. 安装相关软件,搭建环境 sudo apt install qt- creator sudo apt install qt5- default source python35/bin/activate pip install pyqt5 2. 输入qtcreator,打开设计界面,进行相关控件拖放和属性配置即可。 简单的加减小例子 #include " mainwindow.h " #include " ui_mainwindow.h " MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), ui( new Ui::MainWindow) { ui ->setupUi( this ); } MainWindow:: ~ MainWindow() { delete ui; } void MainWindow::on_add_clicked(){ int res = ui->M->text().toInt()+ ui->N-> text().toInt(); ui ->result-> setText(QString::number(res)); } void MainWindow::on_sub_clicked() { int res = ui->M->text().toInt() - ui->N->

any python lightweight gui library? [closed]

蓝咒 提交于 2021-01-04 12:55:11
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question I've tried using pyinstaller to package a simple hello world example using both pyqt and wxPython and both of them were about 15mb to 20mb. Why is it so big , its not practical for simple apps. Is there any other cross-platform solutions? 回答1: For small

any python lightweight gui library? [closed]

孤人 提交于 2021-01-04 12:50:53
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question I've tried using pyinstaller to package a simple hello world example using both pyqt and wxPython and both of them were about 15mb to 20mb. Why is it so big , its not practical for simple apps. Is there any other cross-platform solutions? 回答1: For small

any python lightweight gui library? [closed]

偶尔善良 提交于 2021-01-04 12:50:06
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question I've tried using pyinstaller to package a simple hello world example using both pyqt and wxPython and both of them were about 15mb to 20mb. Why is it so big , its not practical for simple apps. Is there any other cross-platform solutions? 回答1: For small

How to make the background color the same as the form background?

余生颓废 提交于 2021-01-01 04:19:43
问题 In PyQt5 I'm getting some unexpected behavior from QTabWidget, the background seems to be white instead of the default form color (roughly light gray). Here is an example: # QTabWidget2.py from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLabel, QHBoxLayout, QVBoxLayout, QTabWidget, \ QGraphicsView, QFrame, QGridLayout from PyQt5.QtGui import QPalette from PyQt5.Qt import Qt def main(): app = QApplication([]) mainForm = MainForm() mainForm.show() app.exec() # end main class