PyQT5: QTextEdit 選取文字測試

利用QTextCursor取得指針位置,修改選取參數查看顯示效果

QTextCursor選取參數:

  • Document 3 Selects the entire document. 選取全部
  • BlockUnderCursor 2 Selects the block of text under the cursor. 選取到cursor位置的block
  • LineUnderCursor 1 Selects the line of text under the cursor. 選取與cursor位置同一行
  • WordUnderCursor 0 Selects the word under the cursor. 選取cursor位置的單字

EX: Document

 

全部選取效果(Document)

依序測試其他效果
BlockUnderCursor

LineUnderCurosr

WordUnderCursor

 

 

 

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *