QtCore.Qt.WindowStaysOnTopHint
Example:html
# -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QApplication , QMainWindow from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(368, 164) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) if __name__ == '__main__': ''' 主函數 ''' app = QApplication(sys.argv) mainWindow = QMainWindow() ui = Ui_MainWindow() ui.setupUi(mainWindow) mainWindow.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) mainWindow.show() sys.exit(app.exec_())
API參考app
前提條件:得到指針對象函數
textCursor = self.textEdit.textCursor()
獲取指定區間的文本(相對於整篇文檔)ui
textCursor.setPosition(3, QTextCursor.MoveAnchor) textCursor.setPosition(9, QTextCursor.KeepAnchor) lineContent = textCursor.selectedText()
str = '0123456789'
3-9之間的字符爲 345678指針
獲取光標所在行的文本code
textCursor.select(QTextCursor.LineUnderCursor) lineContent = textCursor.selectedText()
獲取光標所在行的文本的前5個字符htm
textCursor.movePosition(QTextCursor.StartOfLine) end = textCursor.position() + 5 textCursor.setPosition(end, QTextCursor.KeepAnchor)