本文整理匯總了Python中PyQt5.QtWidgets.QLineEdit.setDragEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Python QLineEdit.setDragEnabled方法的具體用法?Python QLineEdit.setDragEnabled怎麽用?Python QLineEdit.setDragEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QLineEdit
的用法示例。
在下文中一共展示了QLineEdit.setDragEnabled方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init_ui
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setDragEnabled [as 別名]
def __init_ui(self):
self.setWindowTitle(self.title)
self.setGeometry(self.left, self.top, self.width, self.height)
edit_box = QLineEdit('Drag this', self)
edit_box.setDragEnabled(True)
edit_box.move(10, 10)
edit_box.resize(200, 32)
label = CustomLabel('Drop here.', self)
label.move(10, 50)
label.resize(200, 32)
示例2: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setDragEnabled [as 別名]
def __init__(self):
super().__init__()
editBox = QLineEdit('Drag this', self)
editBox.setDragEnabled(True)
editBox.move(10, 10)
editBox.resize(100, 32)
button = CustomLabel('Drop here.', self)
button.move(130, 15)
self.show()
示例3: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setDragEnabled [as 別名]
def initUI(self):
edit = QLineEdit('', self)
edit.setDragEnabled(True)
edit.move(30, 35)
button = Button("Button", self)
button.move(190, 35)
self.setAcceptDrops(True)
self.button = Button('Click or Move', self)
self.button.move(100, 100)
self.setWindowTitle('drag & drop')
self.setGeometry(300, 300, 300, 150)
示例4: MainWindow
# 需要導入模塊: from PyQt5.QtWidgets import QLineEdit [as 別名]
# 或者: from PyQt5.QtWidgets.QLineEdit import setDragEnabled [as 別名]
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.current_dir = os.getcwd()
self.descriptors = {}
self.image_names = []
self.current_index = 0
self.pixmap = None
self.scaledPixmap = None
self.initUI()
self.reloadDirectory()
def initUI(self):
centralWidget = QWidget()
self.setCentralWidget(centralWidget)
self.statusBar()
# menu
openIcon = qApp.style().standardIcon(QStyle.SP_DirOpenIcon)
openFolder = QAction(openIcon, 'Open folder..', self)
openFolder.setShortcut('Ctrl+O')
openFolder.setStatusTip('Open a new folder with images')
openFolder.triggered.connect(self.showDialog)
exitIcon = qApp.style().standardIcon(QStyle.SP_DialogCloseButton)
exitAction = QAction(exitIcon, '&Exit', self)
exitAction.setShortcut('Ctrl+Q')
exitAction.setStatusTip('Exit application')
exitAction.triggered.connect(qApp.quit)
menubar = self.menuBar()
menubar.setNativeMenuBar(False)
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(openFolder)
fileMenu.addAction(exitAction)
aboutMenu = menubar.addMenu('&About')
aboutAction = QAction('&About', self)
aboutAction.setShortcut('F1')
aboutAction.setStatusTip('About the author')
aboutAction.triggered.connect(self.about)
aboutMenu.addAction(aboutAction)
# window contents
self.label = CustomQLabel(self)
self.label.setMinimumSize(1, 1)
self.label.setAlignment(Qt.AlignCenter)
self.label.mousePressEvent = self.handleImageClick
self.label.installEventFilter(self)
self.commentEdit = QLineEdit()
self.commentEdit.setPlaceholderText("Enter comment here...")
self.commentEdit.setDragEnabled(True) # Allows drag-n-drop in the text field
self.commentEdit.textChanged.connect(self.saveComment)
prevIcon = qApp.style().standardIcon(QStyle.SP_ArrowBack)
prevButton = QPushButton("Previous image")
prevButton.setIcon(prevIcon)
prevButton.setToolTip("PageUp")
nextIcon = qApp.style().standardIcon(QStyle.SP_ArrowForward)
nextButton = QPushButton("Next image")
nextButton.setIcon(nextIcon)
nextButton.setToolTip("PageDown")
prevButton.clicked.connect(self.moveBackward)
nextButton.clicked.connect(self.moveForward)
hbox = QHBoxLayout()
hbox.addWidget(self.commentEdit)
hbox.addWidget(prevButton)
hbox.addWidget(nextButton)
vbox = QVBoxLayout()
vbox.addWidget(self.label)
vbox.addLayout(hbox)
centralWidget.setLayout(vbox)
# window itself
self.setGeometry(300, 300, 800, 480)
self.center()
self.setWindowTitle('Tickster')
self.show()
def about(self):
QMessageBox.about(self, "About",
"""<b> Tickster version %s </b>
<p>Copyright © by Dmitry Nikulin. October 2015.
<ul>
<li>Python %s</li>
<li>PyQt %s</li>
<li>Qt %s</li>
</ul>
<p>Esc to exit, Ctrl+O to open a folder, PageUp/PageDown to navigate.</p>
<p>Data is saved automatically in <b>%s</b> when switching between images,
directories, and on exit.</p>""" %
#.........這裏部分代碼省略.........