pyqt5 带有复选框的可多选的Combox

python -- pyQt5 QListWidget-多重选择 QCheckBox-复选框 【代码】python -- pyQt5 QListWidget 多重选择。 阅读详情

#pyqt5 带有复选框的可多选的Combox#

## 扩展字 QCombox

案例截图

## 代码

from PyQt5.QtWidgets import QComboBox, QLineEdit, QListWidgetItem, QListWidget, QCheckBox, \
    QApplication, QVBoxLayout, QWidget, QPushButton
import sys


# Ctrl+Alt+L 自动格式化代码
"""
# 多选Combox框1
class ComboCheckBox(QComboBox):
    def __init__(self, items: list):
        super(ComboCheckBox, self).__init__()
        self.items = ["全选"] + items  # items list
        self.box_list = []  # selected items
        self.text = QLineEdit()  # use to selected items
        self.state = 0  # use to record state
        q = QListWidget()
        for i in range(len(self.items)):
            self.box_list.append(QCheckBox())
            self.box_list[i].setText(self.items[i])
            item = QListWidgetItem(q)
            q.setItemWidget(item, self.box_list[i])
            if i == 0:
                self.box_list[i].stateChanged.connect(self.all_selected)
            else:
                self.box_list[i].stateChanged.connect(self.show_selected)
        q.setStyleSheet("font-size: 18px;  height: 35px; margin-left: 5px") # font-weight: bold;
        self.setStyleSheet("width: 300px; height: 35px; font-size: 20px;")
        self.text.setReadOnly(True)
        self.setLineEdit(self.text)
        self.setModel(q.model())
        self.setView(q)

    def all_selected(self):
        # change state
        if self.state == 0:
            self.state = 1
            for i in range(1, len(self.items)):
                self.box_list[i].setChecked(True)
        else:
            self.state = 0
            for i in range(1, len(self.items)):
                self.box_list[i].setChecked(False)
        self.show_selected()

    def get_selected(self):
        ret = []
        for i in range(1, len(self.items)):
            if self.box_list[i].isChecked():
                ret.append(self.box_list[i].text())
        return ret

    def show_selected(self):
        self.text.clear()
        ret = '; '.join(self.get_selected())
        self.text.setText(ret)




class UiMainWindow(QWidget):
    def __init__(self):
        super(UiMainWindow, self).__init__()
        self.setWindowTitle('Test')
        self.resize(600, 400)
        combo = ComboCheckBox(["Python", "Java", "Go", "C++", "JavaScript", "PHP"])
        layout = QVBoxLayout()
        layout.addWidget(combo)
        self.setLayout(layout)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ui = UiMainWindow()
    ui.show()
    sys.exit(app.exec_())





"""
# from PyQt5.QtWidgets import QComboBox, QLineEdit, QListWidget, QCheckBox, QListWidgetItem

# # 多选Combox框2
class ComboCheckBox(QComboBox):
    def loadItems(self, items):
        self.items = items
        self.items.insert(0, '全部')
        self.row_num = len(self.items)
        self.Selectedrow_num = 0
        self.qCheckBox = []
        self.qLineEdit = QLineEdit()
        self.qLineEdit.setReadOnly(True)
        self.qListWidget = QListWidget()
        self.addQCheckBox(0)
        self.qCheckBox[0].stateChanged.connect(self.All)
        for i in range(0, self.row_num):
            self.addQCheckBox(i)
            self.qCheckBox[i].stateChanged.connect(self.showMessage)
        self.setModel(self.qListWidget.model())
        self.setView(self.qListWidget)
        self.setLineEdit(self.qLineEdit)
        # self.qLineEdit.textChanged.connect(self.printResults)

    def showPopup(self):
        #  重写showPopup方法,避免下拉框数据多而导致显示不全的问题
        select_list = self.Selectlist()  # 当前选择数据
        self.loadItems(items=self.items[1:])  # 重新添加组件
        for select in select_list:
            index = self.items[:].index(select)
            self.qCheckBox[index].setChecked(True)  # 选中组件
        return QComboBox.showPopup(self)

    def printResults(self):
        list = self.Selectlist()
        print(list)

    def addQCheckBox(self, i):
        self.qCheckBox.append(QCheckBox())
        qItem = QListWidgetItem(self.qListWidget)
        self.qCheckBox[i].setText(self.items[i])
        self.qListWidget.setItemWidget(qItem, self.qCheckBox[i])

    def Selectlist(self):
        Outputlist = []
        for i in range(1, self.row_num):
            if self.qCheckBox[i].isChecked() == True:
                Outputlist.append(self.qCheckBox[i].text())
        self.Selectedrow_num = len(Outputlist)
        return Outputlist

    def showMessage(self):
        Outputlist = self.Selectlist()
        self.qLineEdit.setReadOnly(False)
        self.qLineEdit.clear()
        show = ';'.join(Outputlist)

        if self.Selectedrow_num == 0:
            self.qCheckBox[0].setCheckState(0)
        elif self.Selectedrow_num == self.row_num - 1:
            self.qCheckBox[0].setCheckState(2)
        else:
            self.qCheckBox[0].setCheckState(1)
        self.qLineEdit.setText(show)
        self.qLineEdit.setReadOnly(True)

    def All(self, zhuangtai):
        if zhuangtai == 2:
            for i in range(1, self.row_num):
                self.qCheckBox[i].setChecked(True)
        elif zhuangtai == 1:
            if self.Selectedrow_num == 0:
                self.qCheckBox[0].setCheckState(2)
        elif zhuangtai == 0:
            self.clear()

    def clear(self):
        for i in range(self.row_num):
            self.qCheckBox[i].setChecked(False)

    def currentText(self):
        text = QComboBox.currentText(self).split(';')
        if text.__len__() == 1:
            if not text[0]:
                return []
        return text


if __name__ == '__main__':
    from PyQt5 import QtWidgets, QtCore
    import sys

    items = ['Python', 'R', 'Java', 'C++', 'CSS']

    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    comboBox1 = ComboCheckBox(Form)
    comboBox1.setGeometry(QtCore.QRect(10, 10, 100, 20))
    comboBox1.setMinimumSize(QtCore.QSize(100, 20))
    comboBox1.loadItems(items)


    searchBtn = QPushButton(Form)
    searchBtn.clicked.connect(lambda:print(comboBox1.currentText()))

    Form.show()
    sys.exit(app.exec_())
    


基于pyside2(pyqt5)和pymodbus实现的modbus协议通信界面程序 本次项目python版本环境: python3.10.9所需要的库: PySide2、pymodbus、serial、threading、time1.命令行输入(下载慢的话可使用国内镜像源下载,之前的文章我讲过)2.安装modbus仿真工具,modbus Poll和modbus slave。两个软件都只有几兆,去网上随便一搜就有很多,所以这两个软件还请大家自行下载。3.安装Configure Virtual Serial Port Driver,用来创建虚拟串口。 阅读详情

相关推荐

PyQt5中QComboBox实现多选功能

在PyQt5中,QComboBox是一个常用的下拉框控件,它允许用户从预定义的选项列表中选择一个值。在上述代码中,我们创建了一个垂直布局管理器(QVBoxLayout),并将其设置为窗口的布局。然后,我们创建了一个QComboBox控件,并对其进行了一些设置。在上述代码中,我们创建了一个垂直布局管理器(QVBoxLayout),并将其设置为窗口的布局。然后,我们创建了一个QComboBox控件,并对其进行)在上述代码中,我们创建了一个垂直布局管理器(QVBoxLayout)

XdKwargs的博客 1626

PyQt5快速上手基础篇9-QCombox用法

前言 本节我们学习使用Qt Designer使用QComboBox。 一、基础知识 1.QCombox简介 QComboBox对象显示一个下拉列表可供选择,是一个集按钮和下拉选项于一体的控件,也称做下拉列表框。此外,QCombox允许用户修改列表的每个项目。 QCombox常用方法如下: QCombox信号: 二、实例 1. QT Designer设计UI 复制“ pyqt5快速上手基础篇8-菜单栏、工具栏和状态栏“中image文件夹内容和action_tool.ui,并修改action_tool.ui

weixin_45006076的博客 7110

使用pyQt5创建ComboBox及其用法

ComboBox(组合框)是pyQt5中常用的UI控件之一,它提供了一个下拉菜单和一个可编辑的文本框,用户可以从下拉菜单中选择一个选项,或者手动输入文本。在上述示例中,我们定义了一个槽函数on_combobox_changed(),当ComboBox的选项发生变化时,该函数将被调用。ComboBox的选项可以通过addItem()方法逐个添加,也可以使用addItems()方法一次性添加多个选项。在initUI()方法中,我们创建了一个垂直布局管理器,并将其设置为窗口的布局管理器。

RbvAlgorithm的博客 649

PyQt5基本窗口控件(六)QCombox

QComboBox下拉列表框,是一个比较有意思的按钮控件,在我们遇到的程序中,经常还链接到数据库中的字典选项,如中国各民族、各省份等

alijunshan的博客 2406

Android11,无障碍服务模拟多手势使用dispatchGesture时总是onCancelled

AccessibilityService的dispatchGesture去模拟多手势,总是onCancelled的一种解决办法

m0_49953943的博客 2102

手把手教你用GEM-2多频电磁仪找地下管道(附真实数据图)

本文详细解析了使用GEM-2多频电磁仪精准定位地下管线的全流程,包括设备调试、频率选择、现场扫描技巧及数据解读。通过真实案例展示了如何应对复杂干扰环境,提升管线检测效率与准确性,特别适合市政工程和地下管线普查。

weixin_42565652的博客 398

PyQt中QComBox自定义属性,并能够获得所选内容的复选框

网上找不到合适的自定义item内容并能够获得复选内容的combox,所以自己写了个,有需要的直接拿去用即可: from PyQt5.QtWidgets import QComboBox, QLineEdit, QListWidget, QCheckBox, QListWidgetItem from PyQt5 import QtWidgets import sys class ComboCheck...

qq_33259774的博客 1762

Framelet Transform

需要定义 Framelet 的基函数。Framelet 基函数可以是通过组合不同的小波函数生成的。# 这里可以定义 Framelet 基函数,例如一些小波基函数的线性组合# 这是一个示例函数,具体实现需要根据具体的 Framelet 设计# 示例:正弦函数。

qq_33009429的博客 1211

PyQt5 复选框 QComboBox加入 checkbox

参考代码: https://blog.youkuaiyun.com/LJX4ever/article/details/78039318 俄国佬的写的好 http://qaru.site/questions/1796930/checkboxes-in-a-combobox-using-pyqt [/code] https://www.jianshu.com/p/d7b3516ff046 https://blog.youkuaiyun.com/Up_junior/article/details/81606191 ...

abc 2183

服务器取证——服务器基础知识

服务器基础知识

记录并分享学习安全的知识点.. 2482

司法AI系统的架构设计:法律知识图谱如何辅助智能庭审?架构师亲测

简单来说,法律知识图谱是一种采用图数据结构(节点Node + 边Edge/关系Relation)来组织和表达法律领域知识的语义网络。它以。

AI 算法实战派 1088

pyqt学习191012

1,checkbox下复选框的第三种状态,注意在pyqt5下可以,在pyside2下不可以, 半选中状态pysdie2不行,注意pyqt5下,需要设置两个地方, checkbox.setTristate(True)启用半选状态, checkbox.setCheckState(Qt.PartiallyChecked),设置为半选状态。 checkbox 利用statechanged 来绑...

sdzzlove的专栏 185

【unity游戏开发入门到精通——UGUI】文本控件 —— TextetMeshPro新文本控件(TextMeshPro - Text(UI)和TextMeshPro - Text)

文本组件是UGUI中最常用的组件,它的作用是对文本数据进行处理并显示。UGUI的文本组件可以分两为种——Text旧文本控件、TextMeshPro新文本组件。本文主要是介绍TextMeshPro新文本控件,而TextMeshPro新文本控件又可以分为两种——TextMeshPro - Text(UI)和TextMeshPro - Text。TextMeshPro是Unity收购的一个第三方插件,现在已经自动内置到编辑器中,只要使用一次就会自动导入到工程。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 3766

pyqt5的QCombobox添加checkbox功能

from PyQt5 import QtGui, QtCore, QtWidgets import sys, os # subclass class CheckableComboBox(QtWidgets.QComboBox): # once there is a checkState set, it is rendered # here we assume default U...

vample的博客 4179

[知识图谱构建] 一.Neo4j图数据库安装初识及药材供应图谱实例

2012年5月,谷歌公司的知识图谱(Knowledge Graph)产品被正式提出,其旨在将人、地点、物等信息作为实体,将实体间的联系作为关系,并将实体和关系以图的形式进行存储。作为语义网的最新产物,知识图谱这种新型的搜索引擎改变了传统的文本搜索结果,而随后国内公司也开发出了相应产品,例如百度公司的“知心”和搜狗公司的“知立方”等。知识图谱本质上属于一种语义网。知识图谱中的每一条数据或事实一般会采用 <实体,属性,属性值> <实体, 关系,

杨秀璋的专栏 1万+

2 君正底层API接口的封装1

君正的IPC芯片主要有T31、T40、T41等型号,每个型号的API接口大部分是相同的,但也存在一些不一致和差异化的地方。为了屏蔽不同芯片型号之间的差异,我们需要基于一个公共基类进行封装。在封装之前,我们需要定义自己的错误码和数据结构,用于屏蔽不同君正芯片的实现细节。为了确保整个IPC库使用统一的错误码,我们在HP_MPPErrorCode.h文件中专门定义了以下错误码。错误码囊括了参数错误、内存错误、溢出错误、不支持、密码错误、非法数据等各种异常情况。

hope_wisdom的技术博客 1587

pyqt5 tableWidget表格里添加控件并关联函数

tableWidget表格里添加控件并关联函数

夜雨凭栏的博客 8301

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

pyqt5(3)-comboBox-lineEdit-checkBox控件的使用

class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self, parent=None): # super(MainWindow,self).__init__(parent) self.setupUi(self) self.SetLineEdit() # 1. self.SetComboBox() # # self....

aggie4628的专栏 1502

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

企业级PyQt5下QComboBox+QTreeView实现用户可鼠标点击选择树形下拉框中的内容【gif动图演示】

背景与需求: 公司前端有一个下拉框效果,需要移植到PyQt中,我在询问了前端同事的情况下研究了几天,最终做出的效果如下。 因为PyQt这个描述不如前端Vue通用[因为我也是仿造的前端页面原型编写],这里使用前端Vue的描述我们即将要达到的效果。

程序员象漂亮的博客 1167

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

PyQt5--基础篇:用eric6工具实现三级联动效果

今天给大家介绍下python gui界面的三级联动效果,我们用工具eric6来实现,先看下效果图。 首先我们先创建项目linkage,再新建窗体进入到Qt设计师工具开始设计界面,完成后保存并退出。 在eric6工具中编译窗体,再选择生成对话框代码,我们在复选框的函数中勾选on_province_activated(int)这个函数,确认后生成两个新的p...

weixin_30448685的博客 237

Qt Combobox重写 为ComboCheckbox

若输入的和下拉列表里的不同,和下拉列表中选择的 在用户单击确认后一同加入主界面列表中。支持单个输入 多个选择 输入的始终显示在输入框内,不显示多个从类表中选择的选项。若输入的和下拉列表里的相同 下拉类表里默认勾选。

Fewoa的博客 218

PyQt基础_007_ 按钮类控件QCombox

QCombox树状结构。

geji001的博客 946

PyQt5-控件之QCombox(信息/槽signal/slot)

以此文详细理解:信号槽机制,同时,粗略记录QCombox的:currentindexchanged,currenttextchanged,activated三个信号的异同在QT_DESIGNER有一组:信号槽、动作编辑器,如下图:最先接触到:信号槽,简单的理解为对象的信息发送、接受机制, 但同时产生了与“动作”的区别和联系,按照其它基于windows的编程,比如MFC/C++,是不是类似:事件event,但是,后来发现,PyQt这三者都同时存在。

www_djh的博客 1856

pyqt5---combox

combox基本使用

weixin_46058415的博客 788

PyQt6第四章控件功能之4.2常用控件(4.2.8下拉列表框:QComboBox)

当下拉列表框中的选项发生改变时将发送currentIndexChanged信号,关联槽函数selectionChange。循环部分:通过循环遍历下拉列表中的所有项目,找到与选中项匹配的文本,并更新第二个标签的文本,显示用户的选择。addItems():从列表中添加下拉选项。定义一个槽函数,该函数在用户更改下拉列表中的选项时被调用。itemText(i):获取索引为i的item的选项文本。Clear():删除下拉选项集合中的所有选项。count():返回下拉选项集合中的数目。:获取下拉列表中当前选中的文本。

qq_43960238的博客 1813

PyQt6 QComboBox下拉组合框控件

在添加项目之前调用此函数时,将显示占位符文本,否则如果要显示占位符文本,则必须以编程方式调用 setCurrentIndex(-1)。可编辑时设置setSizeAdjustPolicy()将输入内容插入到组合框,是否可以在组合框中插入重复项。如果将最大数量设置为小于组合框中当前项目的数量,则额外的项目将被截断。QComboBox控件,又称为下拉组合框控件,它主要用于在下拉组合框中显示数据,用户可以从中选择项。如果组合框是可编辑的,则当前文本是行编辑显示的值。可编辑时插入的项目应出现在组合框中的位置的策略。

java1234的博客 1421
上一篇: pyqt5 带有复选框的QTreeWidget
下一篇: CenOS7 shell脚本重装OpenSSH
循环盘点
博客等级 码龄15年 552粉丝 14原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值