accept () if _name_ = '_main_' : app = QApplication ( sys. button = Button ( 'Button', self ) self. LeftButton : print ( 'press' ) class Example ( QWidget ): def _init_ ( self ): super (). MimeData = QMimeData () drag = QDrag ( self ) drag. Import sys from PyQt5.QtWidgets import QPushButton, QWidget, QApplication from PyQt5.QtCore import Qt, QMimeData from PyQt5.QtGui import QDrag class Button ( QPushButton ): def _init_ ( self, title, parent ): super (). ![]() setWindowTitle ( 'Simple drag & drop' ) self. move ( 30, 65 ) button = Button ( "Button", self ) button. initUI () def initUI ( self ): edit = QLineEdit ( '', self ) # ドラッグ可能にするĮdit. ![]() ![]() text ()) class Example ( QWidget ): def _init_ ( self ): super (). setAcceptDrops ( True ) def dragEnterEvent ( self, e ): # ドラッグ可能なデータ形式を設定 Import sys from PyQt5.QtWidgets import ( QPushButton, QWidget, QLineEdit, QApplication ) # QPushButtonを継承Ĭlass Button ( QPushButton ): def _init_ ( self, title, parent ): super ().
0 Comments
Leave a Reply. |