码迷,mamicode.com
首页 > 移动开发 > 详细

PyQt4中无边框窗口的移动(拖动)

时间:2014-10-09 18:45:57      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   ar   sp   2014   on   log   

import sys

from PyQt4.QtGui import *

from PyQt4.Qt import *

from PyQt4.QtCore import *

class AboutUsDialog(QDialog):

    def __init__(self):

        super(AboutUsDialog,self).__init__()

        self.setWindowFlags(Qt.FramelessWindowHint|Qt.Dialog)

    def mousePressEvent(self, e):

        if e.button()==Qt.LeftButton:

            self.move1=e.globalPos()-self.frameGeometry().topLeft()

            QApplication.postEvent(self,QEvent(174))

            e.accept()

    def mouseMoveEvent(self, e):

        if e.buttons()==Qt.LeftButton:

            self.move(e.globalPos()-self.move1)

            e.accept()

 

app = QApplication(sys.argv)

aboutus = AboutUsDialog()

aboutus.show()

sys.exit(app.exec_())

如图:bubuko.com,布布扣

PyQt4中无边框窗口的移动(拖动)

标签:blog   http   io   os   ar   sp   2014   on   log   

原文地址:http://www.cnblogs.com/mhxy13867806343/p/4013515.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!