def setColor(self): # 避免窗口置顶后,Dialog被主窗口覆盖,所以需要传递self # 设定默认颜色使用getColor的第一个参数(使用setCurrentColor不生效) # "选择颜色" 为Dialog弹窗的标题 # 设定QColorDialog.ColorDialogOption.ShowAlphaChannel 显示透明度设定 color = QColorDialog(self).getColor( QColor(24, 24, 24, 240), self, "选择颜色", QColorDialog.ColorDialogOption.ShowAlphaChannel) if color.isValid(): print(color.name()) print(str(color.alpha()))
标签:24,颜色,python,QColorDialog,pyqt6,color,self,弹窗 From: https://www.cnblogs.com/uoky/p/17970300