/usr/bin/env python from PyQt5 import QtCore, QtGui,QtWidgets from PyQt5.QtPrintSupport import QPrinter...(printer)#使用painter 绘制文字、pixmap等在printer上 painter.setRenderHint(QtGui.QPainter.Antialiasing)#...") def createActions(self): self.openAct = QtWidgets.QAction("&Open...", self, shortcut="Ctrl+O", triggered=self.open) self.printAct = QtWidgets.QAction...("&About", self, triggered=self.about) self.aboutQtAct = QtWidgets.QAction("About &Qt", self,
在Qt中使用QAction来表示窗口的动作,就是窗口上发生的事件。 QAction包含了图标、菜单文字、快捷键、状态栏文字、浮动帮助等信息。...当把一个QAction对象添加到程序中时,Qt自己选择使用哪个属性来显示,无需我们关心。同时,Qt 能够保证把QAction对象添加到不同的菜单、工具栏时,显示内容是同步的。...也就是说,如果我们在菜单中修改了QAction的图标,那么在工具栏上面这个QAction所对应的按钮的图标也会同步修改。
__init__() self.initUI() def initUI(self): exitAction = QtGui.QAction(QtGui.QIcon...exitAction = QtGui.QAction(QtGui.QIcon('exit.png')) exitAction.setShortcut('Ctrl+Q') exitAction.setStatusTip...('Exit application') QtGui.QAction 是一个 action 的抽象,包括菜单栏,工具栏或者是自定义的快捷键。...__init__() self.initUI() def initUI(self): exitAction = QtGui.QAction(QtGui.QIcon...exitAction = QtGui.QAction(QtGui.QIcon('exit24.png'), 'Exit', self) exitAction.setShortcut('Ctrl+Q')
下面是代码: # -*- coding: utf-8 -*- from PyQt4 import QtGui ,Qt ,QtCore image=QtGui.QImage() bgImage=image.load...self.pushButton_login, QtCore.SIGNAL("clicked()"),self.log_in) def contextMenu(self): self.userOption = QtGui.QAction...(QtGui.QIcon("images/user.png"),u"学生", self) self.rootOption = QtGui.QAction(QtGui.QIcon("...(u"学生体能健康测试软件") self.restoreAction = QtGui.QAction(img_main,u"打开主窗口", self) self.restoreAction.triggered.connect...(self.showNormal) self.quitAction = QtGui.QAction(img_exit,u"退出", self) self.quitAction.triggered.connect
self.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) self.actionopenpic = QtWidgets.QAction...(self) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/images/1.png"), QtGui.QIcon.Normal...self.action.triggered.connect(self.open_video) self.action_2 = QtWidgets.QAction(self)...icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/images/3.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off...2") self.action_2.triggered.connect(self.open_camera) self.actionexit = QtWidgets.QAction