[Interest] How to get word that was clicked on in a table view or table widget?
Tony Rietwyk
tony at rightsoft.com.au
Sat Oct 12 07:48:24 CEST 2013
Hi Alexei,
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
the cell
- 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,
Tony.
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
Alexei Vinidiktov
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:
Hello,
I need to get the word that was clicked on in a table widget or table view
cell.
Is it possible? If so, how would I do that?
Thanks.
--
Alexei Vinidiktov
--
Alexei Vinidiktov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131012/7c5e6c26/attachment.html>
More information about the Interest
mailing list