pyqt 测试模板 子窗口 addChildWidget 覆盖 遮罩 半透明

Qt程序设计-半透明遮罩效果窗口实现 本文讲解如何实现Qt半透明遮罩效果窗口。 阅读详情

代码如下:

import sys
from PyQt5.QtWidgets import QWidget, QToolTip, QApplication
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys


class ChildOneWin(QWidget):
    def __init__(self, parent=None):
        super(ChildOneWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()
        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildOneWin_wdt")
        self.top_widget.setStyleSheet("#ChildOneWin_wdt{background:rgb(255,255,255)}")
        self.main_layout.addWidget(self.top_widget)
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)
        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口1')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)


class ChildTwoWin(QWidget):
    def __init__(self, parent=None):
        super(ChildTwoWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()

        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildTwoWin_wdt")
        self.top_widget.setStyleSheet("#ChildTwoWin_wdt{background:rgb(255,0,0)}")
        self.main_layout.addWidget(self.top_widget)

        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)

        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口2')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)


class ChildThreeWin(QWidget):
    def __init__(self, parent=None):
        super(ChildThreeWin, self).__init__(parent)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.BypassWindowManagerHint | Qt.Tool | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt = QWidget()
        #self.wdt.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt.setObjectName("tipWaitingWindow_back")
        self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}")

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.wdt)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        main_layout = QVBoxLayout()

        self.wdt.setLayout(main_layout)

        self.test_btn = QPushButton('窗口3')
        main_layout.addWidget(self.test_btn)
        main_layout.addStretch(1)


class WinUIform(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle('透明窗口测试')
        self.resize(330, 350)

        main_layout = QVBoxLayout()

        self.setLayout(main_layout)


        top_widget = QWidget()
        top_widget_layout = QHBoxLayout()
        top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('测试')
        self.test_btn.clicked.connect(self.call_back_test_btn)

        self.control_btn = QPushButton('控制')
        self.control_btn.clicked.connect(self.call_back_control_btn)

        self.show_btn = QPushButton('显示')
        self.show_btn.clicked.connect(self.call_back_show_btn)

        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.control_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.show_btn)

        self.bottom_widget = QWidget()

        main_layout.addWidget(top_widget)
        main_layout.addWidget(self.bottom_widget)
        main_layout.setStretch(0, 1)
        main_layout.setStretch(1, 5)

        self.child_one_win = ChildOneWin()
        self.child_two_win = ChildTwoWin()
        self.child_three_win = ChildThreeWin()

        self.bottom_widget_layout = QHBoxLayout()

        self.bottom_widget.setLayout(self.bottom_widget_layout)
        self.bottom_widget_layout.addWidget(self.child_one_win)
        #self.bottom_widget_layout.addChildWidget(self.child_two_win)

        #self.child_two_win.setGeometry(50, 50, 200, 200)

    def call_back_show_btn(self):
        top_rect = self.bottom_widget.geometry()
        print(top_rect)
        self.bottom_widget_layout.addChildWidget(self.child_three_win)
        self.child_three_win.resize(top_rect.width(), top_rect.height())

    def call_back_test_btn(self):
        pass

    def call_back_control_btn(self):
        pass




if __name__ == '__main__':
    app = QApplication(sys.argv)
    # 下面两种方法都可以
    win = WinUIform()
    #win = Winform()
    win.show()
    sys.exit(app.exec_())

运行效果如下:

在这里插入图片描述

1

https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtwidgets/qlayout.html

https://doc.qt.io/qt-5/qlayout.html#addChildWidget

PyQt5.QtWidgets.QLayout
Inherits from QObject, QLayoutItem.

Inherited by QBoxLayout, QFormLayout, QGridLayout, QStackedLayout.

addChildLayout(QLayout)
TODO

addChildWidget(QWidget)
TODO

使用resizeEvent 来调整适应窗口的大小
import sys
from PyQt5.QtWidgets import QWidget, QToolTip, QApplication
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys


class ChildOneWin(QWidget):
    def __init__(self, parent=None):
        super(ChildOneWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()
        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildOneWin_wdt")
        self.top_widget.setStyleSheet("#ChildOneWin_wdt{background:rgb(255,255,255)}")
        self.main_layout.addWidget(self.top_widget)
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)
        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口1')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)


class ChildTwoWin(QWidget):
    def __init__(self, parent=None):
        super(ChildTwoWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()

        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildTwoWin_wdt")
        self.top_widget.setStyleSheet("#ChildTwoWin_wdt{background:rgb(255,0,0)}")
        self.main_layout.addWidget(self.top_widget)

        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)

        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口2')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)


class ChildThreeWin(QWidget):
    def __init__(self, parent=None):
        super(ChildThreeWin, self).__init__(parent)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.BypassWindowManagerHint | Qt.Tool | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt = QWidget()
        #self.wdt.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt.setObjectName("tipWaitingWindow_back")
        self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}")

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.wdt)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        main_layout = QVBoxLayout()

        self.wdt.setLayout(main_layout)

        self.test_btn = QPushButton('窗口3')
        main_layout.addWidget(self.test_btn)
        main_layout.addStretch(1)


class WinUIform(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle('透明窗口测试')
        self.resize(330, 350)

        main_layout = QVBoxLayout()

        self.setLayout(main_layout)


        top_widget = QWidget()
        top_widget_layout = QHBoxLayout()
        top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('测试')
        self.test_btn.clicked.connect(self.call_back_test_btn)

        self.control_btn = QPushButton('控制')
        self.control_btn.clicked.connect(self.call_back_control_btn)

        self.show_btn = QPushButton('显示')
        self.show_btn.clicked.connect(self.call_back_show_btn)

        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.control_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.show_btn)

        self.bottom_widget = QWidget()

        main_layout.addWidget(top_widget)
        main_layout.addWidget(self.bottom_widget)
        main_layout.setStretch(0, 1)
        main_layout.setStretch(1, 5)

        self.child_one_win = ChildOneWin()
        self.child_two_win = ChildTwoWin()
        self.child_three_win = ChildThreeWin()

        self.bottom_widget_layout = QHBoxLayout()

        self.bottom_widget.setLayout(self.bottom_widget_layout)
        self.bottom_widget_layout.addWidget(self.child_one_win)
        self.bottom_widget_layout.addChildWidget(self.child_three_win)

    def resizeEvent(self, event):

        top_rect = self.bottom_widget.geometry()
        print(top_rect)
        self.bottom_widget_layout.addChildWidget(self.child_three_win)
        self.child_three_win.resize(top_rect.width(), top_rect.height())

    def call_back_show_btn(self):
        pass
        # top_rect = self.bottom_widget.geometry()
        # print(top_rect)
        # self.bottom_widget_layout.addChildWidget(self.child_three_win)
        # self.child_three_win.resize(top_rect.width(), top_rect.height())

    def call_back_test_btn(self):
        pass

    def call_back_control_btn(self):
        pass



if __name__ == '__main__':
    app = QApplication(sys.argv)
    # 下面两种方法都可以
    win = WinUIform()
    #win = Winform()
    win.show()
    sys.exit(app.exec_())

多个半透明窗口切换
import sys
from PyQt5.QtWidgets import QWidget, QToolTip, QApplication
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import sys


class ChildOneWin(QWidget):
    def __init__(self, parent=None):
        super(ChildOneWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()
        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildOneWin_wdt")
        self.top_widget.setStyleSheet("#ChildOneWin_wdt{background:rgb(255,255,255)}")
        self.main_layout.addWidget(self.top_widget)
        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)
        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口1')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)


class ChildTwoWin(QWidget):
    def __init__(self, parent=None):
        super(ChildTwoWin, self).__init__(parent)

        self.main_layout = QVBoxLayout()

        self.top_widget = QWidget()
        self.setLayout(self.main_layout)
        self.top_widget.setObjectName("ChildTwoWin_wdt")
        self.top_widget.setStyleSheet("#ChildTwoWin_wdt{background:rgb(255,0,0)}")
        self.main_layout.addWidget(self.top_widget)

        self.main_layout.setContentsMargins(0, 0, 0, 0)
        self.main_layout.setSpacing(0)

        top_widget_layout = QVBoxLayout()
        self.top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('窗口2')
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)


class ChildThreeWin(QWidget):
    def __init__(self, parent=None):
        super(ChildThreeWin, self).__init__(parent)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.BypassWindowManagerHint | Qt.Tool | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt = QWidget()
        #self.wdt.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt.setObjectName("tipWaitingWindow_back")
        self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}")

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.wdt)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        main_layout = QVBoxLayout()

        self.wdt.setLayout(main_layout)

        self.test_btn = QPushButton('窗口3')
        main_layout.addWidget(self.test_btn)
        main_layout.addStretch(1)




class ChildFourWin(QWidget):
    def __init__(self, parent=None):
        super(ChildFourWin, self).__init__(parent)

        self.setWindowFlags(Qt.FramelessWindowHint | Qt.BypassWindowManagerHint | Qt.Tool | Qt.WindowStaysOnTopHint)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt = QWidget()
        #self.wdt.setAttribute(Qt.WA_TranslucentBackground)
        self.wdt.setObjectName("tipWaitingWindow_back")
        self.wdt.setStyleSheet("#tipWaitingWindow_back{background:rgba(0,0,0,0.2)}")

        self.layout = QGridLayout(self)
        self.layout.addWidget(self.wdt)
        self.layout.setContentsMargins(0, 0, 0, 0)
        self.layout.setSpacing(0)

        main_layout = QVBoxLayout()

        self.wdt.setLayout(main_layout)

        self.test_btn = QPushButton('窗口4')
        main_layout.addStretch(1)
        main_layout.addWidget(self.test_btn)
        main_layout.addStretch(1)



class WinUIform(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle('透明窗口测试')
        self.resize(330, 350)

        main_layout = QVBoxLayout()

        self.setLayout(main_layout)


        top_widget = QWidget()
        top_widget_layout = QHBoxLayout()
        top_widget.setLayout(top_widget_layout)

        self.test_btn = QPushButton('测试')
        self.test_btn.clicked.connect(self.call_back_test_btn)

        self.control_btn = QPushButton('控制')
        self.control_btn.clicked.connect(self.call_back_control_btn)

        self.show_btn = QPushButton('显示')
        self.show_btn.clicked.connect(self.call_back_show_btn)

        top_widget_layout.addWidget(self.test_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.control_btn)
        top_widget_layout.addStretch(1)
        top_widget_layout.addWidget(self.show_btn)

        self.bottom_widget = QWidget()

        main_layout.addWidget(top_widget)
        main_layout.addWidget(self.bottom_widget)
        main_layout.setStretch(0, 1)
        main_layout.setStretch(1, 5)

        self.child_one_win = ChildOneWin()
        self.child_two_win = ChildTwoWin()
        self.child_three_win = ChildThreeWin()
        self.child_four_win = ChildFourWin()
        self.bottom_widget_layout = QHBoxLayout()

        self.bottom_widget.setLayout(self.bottom_widget_layout)
        self.bottom_widget_layout.addWidget(self.child_one_win)
        self.bottom_widget_layout.addChildWidget(self.child_three_win)
        self.bottom_widget_layout.addChildWidget(self.child_four_win)
        self.child_three_win.hide()
        self.child_four_win.hide()
    def resizeEvent(self, event):

        top_rect = self.bottom_widget.geometry()
        print(top_rect)
        #self.bottom_widget_layout.addChildWidget(self.child_three_win)
        self.child_three_win.resize(top_rect.width(), top_rect.height())
        self.child_four_win.resize(top_rect.width(), top_rect.height())
    def call_back_show_btn(self):
        pass
        # top_rect = self.bottom_widget.geometry()
        # print(top_rect)
        # self.bottom_widget_layout.addChildWidget(self.child_three_win)
        # self.child_three_win.resize(top_rect.width(), top_rect.height())


    def call_back_test_btn(self):
        pass
        self.child_four_win.show()
        self.child_three_win.hide()

    def call_back_control_btn(self):
        pass
        self.child_four_win.hide()
        self.child_three_win.show()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    # 下面两种方法都可以
    win = WinUIform()
    #win = Winform()
    win.show()
    sys.exit(app.exec_())

Qt之布局设置setLayout详解-源码剖析(下) 大家好,我是前行中的小猪,今天呢给大家继续上一篇之后的内容,再给大家进行一下拓展。 阅读详情

相关推荐

PyQt实现加载遮罩层

在PyQt中,加载遮罩层是一种常见的用户界面效果,它可以在执行耗时操作时显示一个覆盖整个窗口的遮罩层,以指示用户等待。另外,您还可以根据实际情况添加更多的UI元素,如取消按钮或进度条,以提供更多的交互和反馈。在这个类中,我们定义了一个自定义的信号,用于在操作完成后发射信号。然后,我们创建一个自定义的QWidget子类,作为我们的主窗口。在操作完成后,遮罩层将会隐藏,加载中的文本也会消失。现在,当我们运行这段代码时,将会显示一个窗口,并在窗口的中央显示一个加载中的文本。上面的代码示例中,我们使用了。

XdKwargs的博客 576

02:pyqt5的布局管理

布局说白了就是将如何将组件放到我们想要的位置上,即组件如何摆放的问题。

qq_63119830的博客 1344

pyqt5实战之透明样式和页面切换和弹出新窗口

# -*- coding: utf-8 -*- import sys import os import exifread from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import pandas from QSS import qstyle class Child_1(QWidget): def __init__(self): super().__init__(

东方佑 909

PyQt5 教程 《布局管理》

目录 PyQt5中的布局管理 绝对定位 盒子布局 QGridLayout 复习示例 PyQt5中的布局管理 布局管理是我们将小部件放置在应用程序窗口上的方式。我们可以使用绝对定位或布局类来放置小部件。使用布局管理器管理布局是组织窗口小部件的首选方式。 绝对定位 程序员以像素为单位指定每个小部件的位置和大小。当您使用绝对定位时,我们必须了解以下限制: 如果我们调整窗口大小,...

pansaky的博客 1341

python GUI库图形界面开发之PyQt5美化窗体与控件(异形窗体)实例

主要介绍了python GUI库图形界面开发之PyQt5美化窗体与控件(异形窗体)实例,需要的朋友可以参考下

AI 技术新手入门与实战指南

仅仅能对话还不够,实际应用中,我们往往需要让 AI 处理特定的业务数据。比如,从日志文件中提取错误码,或者将非结构化的用户反馈整理成 JSON 格式。这时候,自定义输入和严格的结果验证就显得尤为重要。假设我们需要让 AI 分析一段服务器日志,并只返回错误的级别和简述。请分析以下日志片段,提取所有 ERROR 级别的信息。要求输出格式为 JSON 列表,包含 'timestamp' 和 'message' 两个字段。不要输出任何多余的解释文字。日志内容: {

2600_94936330的博客 2682

PYQT TabelWidget 创建和添加数据

" "最小值", "最大值", "输出值", "结果", "导出参数", "标识", "时间"""最小值", "最大值", "输出值", "结果", "导出参数", "标识"self.tableWidget.setRowCount(len(data)) # 设置行数。self.tableWidget.setColumnCount(6) # 设置列数。self.tableWidget.setColumnCount(7) # 设置列数。# 假设我们想让第一列和最后一列不可编辑。

m0_56219944的博客 1173

实战教程:用YOLOv11+PyQt5打造工地安全帽检测系统(附完整数据集)

本文提供了一份完整的实战指南,详细介绍了如何利用YOLOv11目标检测模型与PyQt5界面库,从零开始构建一个智能工地安全帽检测桌面应用。内容涵盖高质量数据集的准备与标注、YOLOv11模型训练与调优,以及如何使用PyQt5开发流畅、专业的图形用户界面,最终实现一个可实际部署的AI安全监控系统。

plum99的博客 744

PyQt4入门教程(4)_布局管理

注:文中译者自己的话将用方括号【】标出。布局管理(Layout management)是GUI编程中一个重要的方面。布局是我们将各种部件摆放在窗口中的方式。在PyQt4中,布局可以通过两种方式实现:绝对定位(absolute positioning)和layout类。绝对定位在这种方式中,编程者指定各种部件的位置和大小。但是当你使用绝对定位时,需要知道有以下的限制: - 如果我们改变窗口的大小,

浅度寺 1万+

ESP32 Arduino学习篇 (一) 引脚和串口的基本使用

简单来讲arduino就是通过源代码控制开发板的信号输入输出从而实现对一些电子元件的控制,例如LED灯,蜂鸣器,按键arduino程序首先来讲arduino程序是基于C语言,而实现类似对于LED灯和蜂鸣器的简单控制只需简单C语言知识即可实现。arduino程序是基于函数的,而在arduino的库有很多函数,我们只需要调用即可。arduino的程序主体是**setup()函数和loop()**函数以及其它在使用过程中需要构建的函数:setup()函数。

DOF526570的博客 1万+

别再只做游戏了!用虚幻引擎5(UE5)给你的工厂车间做个数字双胞胎(附数据对接教程)

本文详细介绍了如何利用虚幻引擎5(UE5)构建工业数字孪生系统,实现工厂车间的智能可视化。通过UE5的高质量渲染和实时数据处理能力,结合OPC UA和MQTT协议,打造高效的数据对接方案,提升异常识别和设备管理效率。文章还分享了模型优化、可视化设计及典型工业场景的实战案例,助力企业迈向工业4.0。

weixin_33738555的博客 213

代码设置 Qt mainwindow.ui 的布局(Layout)

qt布局设置的2种方法(代码、手动)

qq_52103578的博客 1540

基于aarch64分析kernel源码 六:kernel_init进程(1号进程)、kthreadd进程(2号进程)

kernel_init进程(1号进程)、kthreadd进程(2号进程)分析

OnlyLove_的博客 772

PyQt实现loading遮罩层

优点: 1、完美覆盖整个窗口,阻止点击事件 2、不会阻塞窗口 3、窗口拖动时自动跟随 4、可以使用 gif动图,也可以使用文字 5、使用简单,开包即用 #-*- coding: utf-8 -* __author__ = 'geebos' from PyQt5.Qt import * class LoadingMask(QMainWindow): def __init__(self, p...

渔父歌的博客 4665

【时空数据分析#06】实战:基于Python与ArcGIS的NDVI长期趋势制图与分级

本文详细介绍了基于Python与ArcGIS进行NDVI长期趋势制图与分级分析的完整工作流。通过整合MODIS卫星数据,利用ArcGIS进行空间处理与栅格转换,结合Python进行时序统计与趋势计算,最终生成直观的植被变化趋势分级图,为生态评估与环境监测提供可靠的空间分析工具。

lilh34434的博客 484

机器人视觉仿真软件:PCL (Point Cloud Library)_(8).点云分割技术

点云分割技术在机器人视觉处理中起着至关重要的作用,通过不同的分割方法可以有效地将点云数据中的不同物体或区域分离出来。PCL提供了丰富的分割算法,包括基于平面的分割、基于聚类的分割、基于模型的分割和基于条件的分割等。每种方法都有其适用的场景和优缺点,选择合适的方法可以显著提高点云处理的效率和准确性。希望本节的内容能够帮助读者更好地理解和应用点云分割技术。

kkchenjj的博客 828

GUI编程--PyQt5--布局管理

布局管理

weixin_45228198的博客 1086

openharmony之启动恢复子系统详解

需求: 添加一个名为my_service的自定义服务步骤1: 创建服务配置],],"env": [步骤2: 添加到主配置],"jobs": ["cmds": [步骤3: 验证配置# ✅ 检查配置格式 jq . /system/etc/init/my_service.cfg # 🔄 重新加载配置 begetctl reload # 📊 验证服务状态 begetctl dump_service my_serviceOpenHarmony init进程的完整生命周期。🔄 三阶段启动模型⚙️ 配置体系。

m0_67505153的博客 612

QT 布局管理器(QHBoxLayout/QVBoxLayout/QGridLayout)

1、setcontentmargins设置四周留白(相对于整个窗口的)的间隔;函数原型:void QLayout::setContentsMargins ( int left, int top, int right, int bottom )。 layout1->setContentsMargins(1,0,1,0); 2、setMargin()在控件内部的边距设置。 3、addStretch()在布局里面添加弹簧。 4、setspacing设置控件之间的间隔;注:设置无效的可能原因有,总布

ligare的博客 3118

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

QMediaPlayer播放视频叠加透明元素

本问主要解决QMediaPlayer在播放视频过程中,希望在视频中叠加其他元素显示时候,会出现通过qss设置等方式设置透明背景无效的问题。

热爱远方的心~ 693

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

PyQt5学习总结

可以看到有2个重载版本:将给定的小部件添加到单元格网格的行、列。默认情况下,左上角位置为(0,0)。对齐由对齐指定。默认对齐方式为0,这意味着小部件将填充整个单元格。此版本将给定的小部件添加到单元格网格,跨越多行/列。该单元格将从fromRow、fromColumn开始,跨越rowSpan行和columnSpan列。小部件将具有给定的对齐方式。如果rowSpan和/或columnSpan为-1,则小部件将分别扩展到底部和/或右边缘。使用方法这个版本对应的行列规则的情况。

mjiansun的专栏 1697

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

qt-C++笔记之addItem(), addWidget(), addLayout()

在上面的示例中,我们使用QVBoxLayout创建一个垂直布局,并将其设置为一个QWidget的布局。然后,使用addWidget()函数将QPushButton和QLabel添加到布局中,并指定了不同的参数,如行号、列号和对齐方式。通过使用这些函数,您可以根据需要将小部件和布局组织到不同的容器中,并指定它们的位置和排列方式。是一个用于添加布局的函数,它的作用是将一个布局添加到另一个布局中。它的参数是一个布局对象,可以是。是用于布局管理的函数,它们用于将控件或布局添加到容器中,以实现界面的布局。

小勇博客 1万+

python图形化界面设计例题_实战!在Python中制作精美的图形用户界面

在默认情况下,我们使用PyQt5创建出来的窗口和部件都是自带的默认样式,虽然谈不上很丑,但是也毫无美感可言。其实,在PyQt5中,我们可以有较高的自由度来自定义窗口和各种小部件的样式,通过自定义这些样式,以达到美化图形界面的目的。本篇文章中,我们就通过一个实际的例子,使用QSS和PyQt5的配置属性,实现图形用户界面的美化工作。首先上效果图:使用到的图片素材有9张音乐的封面图片:需要素材的小伙伴可...

weixin_39862484的博客 1724

PyQt5 布局管理(水平、垂直、网格、表单、嵌套、QSplitter)

learn from 《PyQt5 快速开发与实战》 https://doc.qt.io/qtforpython/index.html https://www.riverbankcomputing.com/static/Docs/PyQt5 2. 使用绝对位置布局 使用 坐标 若只给最前面添加一个,则为 若只给最后面添加一个,则为 上面使用了多个空白控件来设置局部布局下面只使用一个空白控件......

Michael是个半路程序员 3646

Qt图形视图框架:QGraphicsLayout

一、描述 QGraphicsLayout 是一个抽象类,用于为QGraphicsLayoutItem及其子项(如QGraphicsWidget)提供布局。QGraphicsWidget 通过 QGraphicsWidget::setLayout() 设置布局。当小部件调整大小时,布局将自动排列小部件的子项。 1.1、编写自定义布局 可以使用 QGraphicsLayout 作为基础来编写自己的自定义布局。创建自定义布局时,必须至少重新实现以下功能: setGeometry():布局的几何形状。 .

友善啊,朋友的博客 2316
上一篇: pyqt5 参考代码 github 参考项目
下一篇: pyqt5 win32gui.获取 win7exe窗体
wowocpp
博客等级 码龄19年 2283粉丝 2077原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值