[Interest] How to get word that was clicked on in a table view or table widget?
tony at rightsoft.com.au
Sat Oct 12 07:48:24 CEST 2013
Interesting question. How does your model get the display text? I assume
your model (or the QTableWidget model) is storing a QString. In the cell
click handler you can theoretically:
- push the display text into a QTextEdit (hidden for release builds)
- format it with the same font, margins, etc, as the cell
- set the max width to the cell width
- use cursorForPosition to get a QTextCursor for the mouse offset within in
- select the current word using select(QTextCursor::WordUnderCursor)
- use selectedText to get the word.
The hard part is mimicking the formatting of the cell, and forcing the text
edit to do its layout changes.
Hope that helps,
From: interest-bounces+tony=rightsoft.com.au at qt-project.org
[mailto:interest-bounces+tony=rightsoft.com.au at qt-project.org] On Behalf Of
Sent: Saturday, 12 October 2013 3:44 PM
To: interest at qt-project.org
Subject: Re: [Interest] How to get word that was clicked on in a table view
or table widget?
I forgot to mention that the table view or table widget is not editable.
On Sat, Oct 12, 2013 at 11:21 AM, Alexei Vinidiktov
<alexei.vinidiktov at gmail.com> wrote:
I need to get the word that was clicked on in a table widget or table view
Is it possible? If so, how would I do that?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest