-
2021-09-14 16:38:46更多相关内容
-
PyQt5实现无边框窗口的标题拖动和窗口缩放
2020-09-20 14:27:02主要为大家详细介绍了PyQt5实现无边框窗口的标题拖动和窗口缩放,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 -
Pyqt实现无边框窗口拖动以及窗口大小改变
2020-09-20 14:27:22主要为大家详细介绍了Pyqt实现无边框窗口拖动及大小改变的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 -
基于PyQt5实现无边框窗口移动、关闭及最小化
2021-06-22 10:03:14PyQt5无边框窗口移动窗口 设置无边框窗口后,标题栏被隐藏,因此无法通过点击标题栏来实现窗口的移动。 # 设置窗体无边框 self.setWindowFlags(Qt.FramelessWindowHint) # 设置背景透明 self.setAttribute(Qt.WA_... -
PyQt5无边框窗口的标题拖动和窗口缩放实现
2017-11-19 12:02:26网上找了半天都找不到好用的PyQt5无边框窗口的实现 借鉴部分前辈的窗口拖放代码 自己捣鼓了一下,实现了一下无边框窗口,问题可能还有一点,慢慢改吧 先做个笔记py文件#!/usr/bin/env python #-*- coding:utf-8 -...网上找了半天都找不到好用的PyQt5无边框窗口的实现
借鉴部分前辈的窗口拖放代码
自己捣鼓了一下,实现了一下无边框窗口,问题可能还有一点,慢慢改吧
先做个笔记py文件
#!/usr/bin/env python #-*- coding:utf-8 -*- from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout from PyQt5.QtCore import Qt, QPoint from PyQt5.QtGui import QFont, QCursor class QTitleLabel(QLabel): """ 新建标题栏标签类 """ def __init__(self, *args): super(QTitleLabel, self).__init__(*args) self.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) self.setFixedHeight(30) class QTitleButton(QPushButton): """ 新建标题栏按钮类 """ def __init__(self, *args): super(QTitleButton, self).__init__(*args) self.setFont(QFont("Webdings")) # 特殊字体以不借助图片实现最小化最大化和关闭按钮 self.setFixedWidth(40) class QUnFrameWindow(QWidget): """ 无边框窗口类 """ def __init__(self): super(QUnFrameWindow, self).__init__(None, Qt.FramelessWindowHint) # 设置为顶级窗口,无边框 self._padding = 5 # 设置边界宽度为5 self.initTitleLabel() # 安放标题栏标签 self.setWindowTitle = self._setTitleText(self.setWindowTitle) # 用装饰器将设置WindowTitle名字函数共享到标题栏标签上 self.setWindowTitle("UnFrameWindow") self.initLayout() # 设置框架布局 self.setMinimumWidth(250) self.setMouseTracking(True) # 设置widget鼠标跟踪 self.initDrag() # 设置鼠标跟踪判断默认值 def initDrag(self): # 设置鼠标跟踪判断扳机默认值 self._move_drag = False self._corner_drag = False self._bottom_drag = False self._right_drag = False def initTitleLabel(self): # 安放标题栏标签 self._TitleLabel = QTitleLabel(self) self._TitleLabel.setMouseTracking(True) # 设置标题栏标签鼠标跟踪(如不设,则标题栏内在widget上层,无法实现跟踪) self._TitleLabel.setIndent(10) # 设置标题栏文本缩进 self._TitleLabel.move(0, 0) # 标题栏安放到左上角 def initLayout(self): # 设置框架布局 self._MainLayout = QVBoxLayout() self._MainLayout.setSpacing(0) self._MainLayout.addWidget(QLabel(), Qt.AlignLeft) # 顶一个QLabel在竖放框架第一行,以免正常内容挤占到标题范围里 self._MainLayout.addStretch() self.setLayout(self._MainLayout) def addLayout(self, QLayout): # 给widget定义一个addLayout函数,以实现往竖放框架的正确内容区内嵌套Layout框架 self._MainLayout.addLayout(QLayout) def _setTitleText(self, func): # 设置标题栏标签的装饰器函数 def wrapper(*args): self._TitleLabel.setText(*args) return func(*args) return wrapper def setTitleAlignment(self, alignment): # 给widget定义一个setTitleAlignment函数,以实现标题栏标签的对齐方式设定 self._TitleLabel.setAlignment(alignment | Qt.AlignVCenter) def setCloseButton(self, bool): # 给widget定义一个setCloseButton函数,为True时设置一个关闭按钮 if bool == True: self._CloseButton = QTitleButton(b'\xef\x81\xb2'.decode("utf-8"), self) self._CloseButton.setObjectName("CloseButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._CloseButton.setToolTip("关闭窗口") self._CloseButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._CloseButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._CloseButton.clicked.connect(self.close) # 按钮信号连接到关闭窗口的槽函数 def setMinMaxButtons(self, bool): # 给widget定义一个setMinMaxButtons函数,为True时设置一组最小化最大化按钮 if bool == True: self._MinimumButton = QTitleButton(b'\xef\x80\xb0'.decode("utf-8"), self) self._MinimumButton.setObjectName("MinMaxButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._MinimumButton.setToolTip("最小化") self._MinimumButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._MinimumButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._MinimumButton.clicked.connect(self.showMinimized) # 按钮信号连接到最小化窗口的槽函数 self._MaximumButton = QTitleButton(b'\xef\x80\xb1'.decode("utf-8"), self) self._MaximumButton.setObjectName("MinMaxButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._MaximumButton.setToolTip("最大化") self._MaximumButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._MaximumButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._MaximumButton.clicked.connect(self._changeNormalButton) # 按钮信号连接切换到恢复窗口大小按钮函数 def _changeNormalButton(self): # 切换到恢复窗口大小按钮 try: self.showMaximized() # 先实现窗口最大化 self._MaximumButton.setText(b'\xef\x80\xb2'.decode("utf-8")) # 更改按钮文本 self._MaximumButton.setToolTip("恢复") # 更改按钮提示 self._MaximumButton.disconnect() # 断开原本的信号槽连接 self._MaximumButton.clicked.connect(self._changeMaxButton) # 重新连接信号和槽 except: pass def _changeMaxButton(self): # 切换到最大化按钮 try: self.showNormal() self._MaximumButton.setText(b'\xef\x80\xb1'.decode("utf-8")) self._MaximumButton.setToolTip("最大化") self._MaximumButton.disconnect() self._MaximumButton.clicked.connect(self._changeNormalButton) except: pass def resizeEvent(self, QResizeEvent): # 自定义窗口调整大小事件 self._TitleLabel.setFixedWidth(self.width()) # 将标题标签始终设为窗口宽度 # 分别移动三个按钮到正确的位置 try: self._CloseButton.move(self.width() - self._CloseButton.width(), 0) except: pass try: self._MinimumButton.move(self.width() - (self._CloseButton.width() + 1) * 3 + 1, 0) except: pass try: self._MaximumButton.move(self.width() - (self._CloseButton.width() + 1) * 2 + 1, 0) except: pass # 重新调整边界范围以备实现鼠标拖放缩放窗口大小,采用三个列表生成式生成三个列表 self._right_rect = [QPoint(x, y) for x in range(self.width() - self._padding, self.width() + 1) for y in range(1, self.height() - self._padding)] self._bottom_rect = [QPoint(x, y) for x in range(1, self.width() - self._padding) for y in range(self.height() - self._padding, self.height() + 1)] self._corner_rect = [QPoint(x, y) for x in range(self.width() - self._padding, self.width() + 1) for y in range(self.height() - self._padding, self.height() + 1)] def mousePressEvent(self, event): # 重写鼠标点击的事件 if (event.button() == Qt.LeftButton) and (event.pos() in self._corner_rect): # 鼠标左键点击右下角边界区域 self._corner_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.pos() in self._right_rect): # 鼠标左键点击右侧边界区域 self._right_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.pos() in self._bottom_rect): # 鼠标左键点击下侧边界区域 self._bottom_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.y() < self._TitleLabel.height()): # 鼠标左键点击标题栏区域 self._move_drag = True self.move_DragPosition = event.globalPos() - self.pos() event.accept() def mouseMoveEvent(self, QMouseEvent): # 判断鼠标位置切换鼠标手势 if QMouseEvent.pos() in self._corner_rect: self.setCursor(Qt.SizeFDiagCursor) elif QMouseEvent.pos() in self._bottom_rect: self.setCursor(Qt.SizeVerCursor) elif QMouseEvent.pos() in self._right_rect: self.setCursor(Qt.SizeHorCursor) else: self.setCursor(Qt.ArrowCursor) # 当鼠标左键点击不放及满足点击区域的要求后,分别实现不同的窗口调整 # 没有定义左方和上方相关的5个方向,主要是因为实现起来不难,但是效果很差,拖放的时候窗口闪烁,再研究研究是否有更好的实现 if Qt.LeftButton and self._right_drag: # 右侧调整窗口宽度 self.resize(QMouseEvent.pos().x(), self.height()) QMouseEvent.accept() elif Qt.LeftButton and self._bottom_drag: # 下侧调整窗口高度 self.resize(self.width(), QMouseEvent.pos().y()) QMouseEvent.accept() elif Qt.LeftButton and self._corner_drag: # 右下角同时调整高度和宽度 self.resize(QMouseEvent.pos().x(), QMouseEvent.pos().y()) QMouseEvent.accept() elif Qt.LeftButton and self._move_drag: # 标题栏拖放窗口位置 self.move(QMouseEvent.globalPos() - self.move_DragPosition) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): # 鼠标释放后,各扳机复位 self._move_drag = False self._corner_drag = False self._bottom_drag = False self._right_drag = False if __name__ == "__main__": from PyQt5.QtWidgets import QApplication import sys app = QApplication(sys.argv) app.setStyleSheet(open("./UnFrameStyle.qss").read()) window = QUnFrameWindow() window.setCloseButton(True) window.setMinMaxButtons(True) window.show() sys.exit(app.exec_())
qss文件
/**********Title**********/ QTitleLabel{ background-color: Gainsboro; font: 100 10pt; } /**********Button**********/ QTitleButton{ background-color: rgba(255, 255, 255, 0); color: black; border: 0px; font: 100 10pt; } QTitleButton#MinMaxButton:hover{ background-color: #D0D0D1; border: 0px; font: 100 10pt; } QTitleButton#CloseButton:hover{ background-color: #D32424; color: white; border: 0px; font: 100 10pt; }
-
PyQt5窗口无边框+窗口拖动+窗口拉伸全部实现
2020-12-17 16:40:12PyQt5窗口无边框+窗口拖动+窗口拉伸全部实现,源码分享给大家。 ...以下内容无关: ...网上找了半天都找不到好用的PyQt5无边框窗口的实现 借鉴部分前辈的窗口拖放代码 自己捣鼓了一下,实现了一下无边框窗口,问题PyQt5窗口无边框+窗口拖动+窗口拉伸全部实现,源码分享给大家。
文件:n459.com/file/25127180-476227195
以下内容无关:
-------------------------------------------分割线---------------------------------------------------------------------
网上找了半天都找不到好用的PyQt5无边框窗口的实现
借鉴部分前辈的窗口拖放代码
自己捣鼓了一下,实现了一下无边框窗口,问题可能还有一点,慢慢改吧
先做个笔记py文件
#!/usr/bin/env python
#-- coding:utf-8 --from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout
from PyQt5.QtCore import Qt, QPoint
from PyQt5.QtGui import QFont, QCursorclass QTitleLabel(QLabel):
“”"
新建标题栏标签类
“”"
def init(self, *args):
super(QTitleLabel, self).init(*args)
self.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)
self.setFixedHeight(30)class QTitleButton(QPushButton):
“”"
新建标题栏按钮类
“”"
def init(self, *args):
super(QTitleButton, self).init(*args)
self.setFont(QFont(“Webdings”)) # 特殊字体以不借助图片实现最小化最大化和关闭按钮
self.setFixedWidth(40)class QUnFrameWindow(QWidget):
“”"
无边框窗口类
“”"
def init(self):
super(QUnFrameWindow, self).init(None, Qt.FramelessWindowHint) # 设置为顶级窗口,无边框
self._padding = 5 # 设置边界宽度为5
self.initTitleLabel() # 安放标题栏标签
self.setWindowTitle = self._setTitleText(self.setWindowTitle) # 用装饰器将设置WindowTitle名字函数共享到标题栏标签上
self.setWindowTitle(“UnFrameWindow”)
self.initLayout() # 设置框架布局
self.setMinimumWidth(250)
self.setMouseTracking(True) # 设置widget鼠标跟踪
self.initDrag() # 设置鼠标跟踪判断默认值def initDrag(self): # 设置鼠标跟踪判断扳机默认值 self._move_drag = False self._corner_drag = False self._bottom_drag = False self._right_drag = False def initTitleLabel(self): # 安放标题栏标签 self._TitleLabel = QTitleLabel(self) self._TitleLabel.setMouseTracking(True) # 设置标题栏标签鼠标跟踪(如不设,则标题栏内在widget上层,无法实现跟踪) self._TitleLabel.setIndent(10) # 设置标题栏文本缩进 self._TitleLabel.move(0, 0) # 标题栏安放到左上角 def initLayout(self): # 设置框架布局 self._MainLayout = QVBoxLayout() self._MainLayout.setSpacing(0) self._MainLayout.addWidget(QLabel(), Qt.AlignLeft) # 顶一个QLabel在竖放框架第一行,以免正常内容挤占到标题范围里 self._MainLayout.addStretch() self.setLayout(self._MainLayout) def addLayout(self, QLayout): # 给widget定义一个addLayout函数,以实现往竖放框架的正确内容区内嵌套Layout框架 self._MainLayout.addLayout(QLayout) def _setTitleText(self, func): # 设置标题栏标签的装饰器函数 def wrapper(*args): self._TitleLabel.setText(*args) return func(*args) return wrapper def setTitleAlignment(self, alignment): # 给widget定义一个setTitleAlignment函数,以实现标题栏标签的对齐方式设定 self._TitleLabel.setAlignment(alignment | Qt.AlignVCenter) def setCloseButton(self, bool): # 给widget定义一个setCloseButton函数,为True时设置一个关闭按钮 if bool == True: self._CloseButton = QTitleButton(b'\xef\x81\xb2'.decode("utf-8"), self) self._CloseButton.setObjectName("CloseButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._CloseButton.setToolTip("关闭窗口") self._CloseButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._CloseButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._CloseButton.clicked.connect(self.close) # 按钮信号连接到关闭窗口的槽函数 def setMinMaxButtons(self, bool): # 给widget定义一个setMinMaxButtons函数,为True时设置一组最小化最大化按钮 if bool == True: self._MinimumButton = QTitleButton(b'\xef\x80\xb0'.decode("utf-8"), self) self._MinimumButton.setObjectName("MinMaxButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._MinimumButton.setToolTip("最小化") self._MinimumButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._MinimumButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._MinimumButton.clicked.connect(self.showMinimized) # 按钮信号连接到最小化窗口的槽函数 self._MaximumButton = QTitleButton(b'\xef\x80\xb1'.decode("utf-8"), self) self._MaximumButton.setObjectName("MinMaxButton") # 设置按钮的ObjectName以在qss样式表内定义不同的按钮样式 self._MaximumButton.setToolTip("最大化") self._MaximumButton.setMouseTracking(True) # 设置按钮鼠标跟踪(如不设,则按钮在widget上层,无法实现跟踪) self._MaximumButton.setFixedHeight(self._TitleLabel.height()) # 设置按钮高度为标题栏高度 self._MaximumButton.clicked.connect(self._changeNormalButton) # 按钮信号连接切换到恢复窗口大小按钮函数 def _changeNormalButton(self): # 切换到恢复窗口大小按钮 try: self.showMaximized() # 先实现窗口最大化 self._MaximumButton.setText(b'\xef\x80\xb2'.decode("utf-8")) # 更改按钮文本 self._MaximumButton.setToolTip("恢复") # 更改按钮提示 self._MaximumButton.disconnect() # 断开原本的信号槽连接 self._MaximumButton.clicked.connect(self._changeMaxButton) # 重新连接信号和槽 except: pass def _changeMaxButton(self): # 切换到最大化按钮 try: self.showNormal() self._MaximumButton.setText(b'\xef\x80\xb1'.decode("utf-8")) self._MaximumButton.setToolTip("最大化") self._MaximumButton.disconnect() self._MaximumButton.clicked.connect(self._changeNormalButton) except: pass def resizeEvent(self, QResizeEvent): # 自定义窗口调整大小事件 self._TitleLabel.setFixedWidth(self.width()) # 将标题标签始终设为窗口宽度 # 分别移动三个按钮到正确的位置 try: self._CloseButton.move(self.width() - self._CloseButton.width(), 0) except: pass try: self._MinimumButton.move(self.width() - (self._CloseButton.width() + 1) * 3 + 1, 0) except: pass try: self._MaximumButton.move(self.width() - (self._CloseButton.width() + 1) * 2 + 1, 0) except: pass # 重新调整边界范围以备实现鼠标拖放缩放窗口大小,采用三个列表生成式生成三个列表 self._right_rect = [QPoint(x, y) for x in range(self.width() - self._padding, self.width() + 1) for y in range(1, self.height() - self._padding)] self._bottom_rect = [QPoint(x, y) for x in range(1, self.width() - self._padding) for y in range(self.height() - self._padding, self.height() + 1)] self._corner_rect = [QPoint(x, y) for x in range(self.width() - self._padding, self.width() + 1) for y in range(self.height() - self._padding, self.height() + 1)] def mousePressEvent(self, event): # 重写鼠标点击的事件 if (event.button() == Qt.LeftButton) and (event.pos() in self._corner_rect): # 鼠标左键点击右下角边界区域 self._corner_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.pos() in self._right_rect): # 鼠标左键点击右侧边界区域 self._right_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.pos() in self._bottom_rect): # 鼠标左键点击下侧边界区域 self._bottom_drag = True event.accept() elif (event.button() == Qt.LeftButton) and (event.y() < self._TitleLabel.height()): # 鼠标左键点击标题栏区域 self._move_drag = True self.move_DragPosition = event.globalPos() - self.pos() event.accept() def mouseMoveEvent(self, QMouseEvent): # 判断鼠标位置切换鼠标手势 if QMouseEvent.pos() in self._corner_rect: self.setCursor(Qt.SizeFDiagCursor) elif QMouseEvent.pos() in self._bottom_rect: self.setCursor(Qt.SizeVerCursor) elif QMouseEvent.pos() in self._right_rect: self.setCursor(Qt.SizeHorCursor) else: self.setCursor(Qt.ArrowCursor) # 当鼠标左键点击不放及满足点击区域的要求后,分别实现不同的窗口调整 # 没有定义左方和上方相关的5个方向,主要是因为实现起来不难,但是效果很差,拖放的时候窗口闪烁,再研究研究是否有更好的实现 if Qt.LeftButton and self._right_drag: # 右侧调整窗口宽度 self.resize(QMouseEvent.pos().x(), self.height()) QMouseEvent.accept() elif Qt.LeftButton and self._bottom_drag: # 下侧调整窗口高度 self.resize(self.width(), QMouseEvent.pos().y()) QMouseEvent.accept() elif Qt.LeftButton and self._corner_drag: # 右下角同时调整高度和宽度 self.resize(QMouseEvent.pos().x(), QMouseEvent.pos().y()) QMouseEvent.accept() elif Qt.LeftButton and self._move_drag: # 标题栏拖放窗口位置 self.move(QMouseEvent.globalPos() - self.move_DragPosition) QMouseEvent.accept() def mouseReleaseEvent(self, QMouseEvent): # 鼠标释放后,各扳机复位 self._move_drag = False self._corner_drag = False self._bottom_drag = False self._right_drag = False
if name == “main”:
from PyQt5.QtWidgets import QApplication
import sys
app = QApplication(sys.argv)
app.setStyleSheet(open("./UnFrameStyle.qss").read())
window = QUnFrameWindow()
window.setCloseButton(True)
window.setMinMaxButtons(True)
window.show()
sys.exit(app.exec_())/Title/
QTitleLabel{
background-color: Gainsboro;
font: 100 10pt;
}/Button/
QTitleButton{
background-color: rgba(255, 255, 255, 0);
color: black;
border: 0px;
font: 100 10pt;
}
QTitleButton#MinMaxButton:hover{
background-color: #D0D0D1;
border: 0px;
font: 100 10pt;
}
QTitleButton#CloseButton:hover{
background-color: #D32424;
color: white;
border: 0px;
font: 100 10pt;
} -
Pyqt实现无边框窗口拖动及改变窗口大小
2015-11-05 17:05:18Pyqt实现无边框窗口拖动及改变窗口大小 -
PyQt5 自定义标题栏,实现无边框,最小化最大化关闭事件,窗口拖动移动,窗口改变大小,仿百度网盘色调美化
2020-08-13 08:43:34PyQt5 自定义标题栏,实现无边框,最小化最大化关闭事件,窗口拖动移动,窗口改变大小,仿百度网盘色调美化 文章目录PyQt5 自定义标题栏,实现无边框,最小化最大化关闭事件,窗口拖动移动,窗口改变大小,仿百度... -
Qt无边框窗口3:自由缩放(各个角+边框)
2020-08-31 21:29:081,简介 前面写过2篇Qt无边框窗口的文章: 文1 介绍主窗口、标题栏制作 文2 增加了右下角缩放窗口 ...Qt无边框窗口3 终极版,自由缩放(各个角+边框): 链接:https://pan.baidu.com/s/1q-LPlyr57E... -
无边框窗口的缩放,UI美化
2010-07-26 22:44:46无边框的窗口实现拖放 跟一般窗口一样的功能 标题栏边框美化,很多同学将边框标题栏去掉就不知道 怎么实现原有的缩放拖大拖小的功能了,其实这很简单 这里我做个例子方便大家参考 并对UI进行了简单的美化 -
PyQt-PySide火影风格无边框不规则窗口
2022-02-04 13:05:17无边框火影界面 -
实战PyQt5: 108-创建不规则窗口
2020-12-11 11:17:19如何创建不规则窗口 在一些应用中,使用不规则的窗口会使应用外观显得更有个性,更符合应用所要表达的功能特点,比如一个炫酷的播放器,一个圆形的模拟时钟等。在QWidget中提供函数setMask()可以方便地实现不规则... -
MayaPython插件开发记录:踩过的坑(三)Pyqt无边框窗口调整大小
2020-12-08 20:45:12def __init__(self, parent=maya_mainWindow()):super(FramelessWin,self).__init__(parent)# 无边框窗口不用framelessWindowFlag的原因是此窗口的父窗口是maya_mainWindow#如果用framelessWindowFlag会导致此窗口... -
无边框窗口FramelessWindowHint实现移动和缩放功能
2018-05-01 12:27:22无边框窗口 在实际软件开发中,UI设计师给你的界面显然Qt的本地化样式是无法满足的。比如QQ的登陆界面,如下图所示: 要是实现这么炫的界面,我们首先要将MainFrame设置FramelessWindowHint无边框,然后再... -
Python+PyQt:使用图标字体打造无边框通用导航界面
2020-12-07 13:29:03相比于其它如C/C++语言,具有上手快、代码少、开发效率高的特点,Qt是跨平台的C++图形用户界面应用程序开发框架,是当前主流的GUI开发工具之一,其在Python下的绑定是PyQt库。使用“Python+PyQt”架构编写应用软件,... -
Hello PyQt5(六)PyQt5 GUI界面设计
2022-02-23 16:39:21一、窗口风格 1、设置窗口风格 Qt实现的窗口样式默认使用的是当前操作系统的原生窗口样式,在不同操作系统下原生窗口样式显示的风格是不一样的。 可以为每个Widget设置风格: setStyle(QStyle style) 获取当前... -
【PyQt】重写系统事件之拖动改变窗口大小
2020-03-05 18:10:08去除系统标题栏并重写拖动改变窗口大小事件 -
pyqt5下实现窗体(比如QWidget类)边框的宽度设置,比如现在软件设计比较流行的“窗体无边框”
2018-07-31 12:10:511、以pyqt5中QWidget类(Form)为例; 2、设置步骤: (1)下图1窗体边框有宽度,如下图1中的4条红线。 图1 (2)如下图2和图3。在Qt Designer界面里,点击下图2中右上角的红框选项“QWidget”,然后滚... -
python3GUI--浏览器By:PyQt5(附源码)
2021-11-03 15:31:49准备工作1.PyQt5:2.Qwebengineview3.PyQt5-tools二.功能展示1.主页2.我的收藏3.浏览历史4.网页截图5.收藏6.复制链接7.网页放大/缩小8.设置-基本9.设置-个性10.设置-隐私11.设置-关于三.设计1.主窗口设计2.设置... -
PyQt5 基本语法(一):基类控件
2022-03-29 13:45:24文章目录PyQt5库(一)一、 简介1、 什么是 Qt2、 什么是PyQt3、 环境搭建二、 基本结构1、 第一个程序2、 控件操作3、 快速生成代码4、 面向对象三、 基类控件1、 QObject1.1 设置标识1.1.1 语法1.1.2 应用场景1.3 ... -
第四节 PyQt5之QWidget对象(可视化控件基类)
2020-02-08 21:38:06QWidget的描述 QWidget是所有的可视化空间的基类; 是一个最简单的空白控件; 控件是用户界面的最小元素; 每个控件都是矩形的,并且...from PyQt5.Qt import * app = QApplication(sys.argv) window = QWidget() ... -
Python pyqt5自定义创建窗口
2022-02-21 09:13:29from PyQt5.QtWidgets import QWidget, QLabel, QPushButton, QVBoxLayout from PyQt5.QtCore import Qt, QPoint from PyQt5.QtGui import QFont, QCursor class QTitleLabel(QLabel): """ 新建标题栏标签类 "... -
PyQt 中 的白色边框问题
2021-12-29 12:46:28思路: Qwidget,QLabel,等组件都是又内外边距...在父窗口嵌套显示子窗口时,同样也是将父窗口和子窗口的内外边距同时设置成0即可消除白色边框的影响 设置上下左右四边距为0: xxx.setContentsMargins(0,0,0,0) ... -
python3+pyqt5+opencv3简单使用(慢慢更新中)
2018-01-24 08:43:59关于python3下搭建pyqt5(pycharm)参考这条链接。 对于pyqt的使用个人比较建议ui设计与逻辑功能分开开发。 下面介绍下简单的使用(通过左侧的目录可直接跳转到相应模块): ui界面的建立 通过pycharm的... -
PyQt5快速入门(六)PyQt5 GUI界面设计
2019-09-18 06:35:28PyQt5快速入门(六)PyQt5 GUI界面设计 一、窗口风格 1、设置窗口风格 Qt实现的窗口样式默认使用的是当前操作系统的原生窗口样式,在不同操作系统下原生窗口样式显示的风格是不一样的。可以为每个Widget设置风格:... -
Python+PyQt5+Mysql(二)通过QSqlQueryModel实现QTableView分页显示,表头排序等功能
2022-04-29 17:15:38bold}") self.tableView.verticalHeader().hide() #---------------------------------------------------------------------------- # 无边框 # self.setWindowFlags(Qt.FramelessWindowHint) #---gtj 设置窗口透明... -
【python版QT学习】pyQT5上位机实战笔记
2020-07-08 10:26:06from…import * 语句与 import 区别 ...程序一直循环运行直到主窗口被关闭终止进程 作用是运行主循环,必须调用此函数才能开始事件处理,调用该方法进入程序的主循环直到调用exit()结束 主事件循 -
《PyQt5快速开发与实战》目录
2019-03-04 18:04:14资源地址:https://github.com/cxinping/PyQt5 目 录 第1章 认识PyQt 5 1 1.1 PyQt框架简介 1 ...1.1.1 PyQt 5的特点 3 ...1.1.2 Qt与PyQt的关系 4 ...1.1.4 PyQt 4/PyQt 5 6 1.1.5 Python 2/Python 3 ...