0

Is there an inbuilt function in Python(preferably in Pyside or PyQt) that would allow me to call the function that the OS calls(or similar) when dragging the cursor over text, selecting it with shift+direction key or pressing ctr+A.

And could I tell this function to trigger when clicking on text and select for example everything with a certain html tag around it. Or something like that.

I hope this question makes sense!

UrbKr
  • 621
  • 2
  • 11
  • 27

1 Answers1

1

Connect the QLineEdit::selectionChanged signal to a function, assuming you are using a QLineEdit. Similar signals exist for other widgets. The function can use QLineEdit::setSelection to set the selection.

Ramchandra Apte
  • 4,033
  • 2
  • 24
  • 44
  • Thanks for the quick answer! I'm using QTextBrowser, and I actually have already connected that signal. However, what I want is for the program to select from where I clicked with the cursor, the text under it according to some kind of filter. In my case, until the end of html highlighted text under the cursor. I hope it's at least vaguely clear what it is i'm asking. – UrbKr Oct 18 '13 at 13:27
  • Good, I can use that. QTextEdit doesn't seem to have such a function, at least I can't find it. If i'm not missing anything I guess I'll just use QLineEdit instead. It's strange, does QTextEdit really not have that functionality? – UrbKr Oct 18 '13 at 13:48
  • The QTextEdit says something about using QTextCursor for setting selections. Should I be looking in to that? – UrbKr Oct 18 '13 at 13:54
  • 1
    @user2724917 See [this SO answer](http://stackoverflow.com/questions/9350622/qtextedit-how-to-select-text-manually) for how to edit the QTextEdit selection. – Ramchandra Apte Oct 18 '13 at 13:56