def selectSetting(self, tabName): """ Highlights a settingsName within the text of the object. """ #-------------------- # Get the text of the widget # then find the index of the 'tabName' #-------------------- text = self.toPlainText() tabNameIndex = text.find(tabName) #-------------------- # Make a cursor, then manually highlight # the text based on the index name and text length. #-------------------- cursor = qt.QTextCursor(self.textCursor()) cursor.setPosition(tabNameIndex, 0) cursor.setPosition(tabNameIndex + len(tabName), 1) self.setTextCursor(cursor) #-------------------- # Run event method. #-------------------- self.onTextSelected()
def mouseReleaseEvent(self, event): """ After the user clicks on a given line. """ #-------------------- # Define a cursor and select the line # that the cursor clicked on. #-------------------- cursor = qt.QTextCursor(self.textCursor()) cursor.select(qt.QTextCursor.LineUnderCursor) #-------------------- # Select the text. #-------------------- self.setTextCursor(cursor) #-------------------- # Run event method. #-------------------- self.onTextSelected()