Expand (drop) text from TableView from button
-
I have TableView for data presentation
in one column I want to have button or ?? something like that to expand
10 maximum of lines, each >= 10 characters
probably QString\n or maybe QList if there is a proper way
If there is no convenient and neat way I would open new QWindow, but its lousy option -
Just you undestand you would want something like:
+----------------------------------+---------+-----------------------------------------+ | Col1 | Col2 | Col3 | +----------------------------------+---------+-----------------------------------------+ | Value 1 | Value 2 | Lorem ipsum dolor sit amet ... | +----------------------------------+---------+-----------------------------------------+And when you press the
...in Col3 it becomes+----------------------------------+---------+-----------------------------------------+ | Col1 | Col2 | Col3 | +----------------------------------+---------+-----------------------------------------+ | Value 1 | Value 2 | Lorem ipsum dolor sit amet, consectetur | | | | adipiscing elit sed do eiusmod tempor | | | | incididunt ut labore et dolore magna | +----------------------------------+---------+-----------------------------------------+correct?
-
Yes, right
but it can be just pushbutton with no text
+----------------------------------+---------+-----------------------------------------+
| Col1 | Col2 | Col3 |
+----------------------------------+---------+-----------------------------------------+
| Value 1 | Value 2 | QPushbutton_ ... |
+----------------------------------+---------+------------------------+----------------+btw, could you share function you draw this table
neat :) -
It is possible, but in order to give you the proper advice, I want to properly understand your request.
So if I understand it right, you want the text in that particular cell to be expanded or collapsed on click on that particular cell ? -
It is possible, but in order to give you the proper advice, I want to properly understand your request.
So if I understand it right, you want the text in that particular cell to be expanded or collapsed on click on that particular cell ?@ankou29666 right
another approach, just place pushbutton/raidobutton/checkbutton
if you can do both, its much appreciated :) -
To the most simple, what I would have done is set the delegate as something like this
Text { text: hoverHandler.hovered ? sourceData.text : sourceData.text.slice(30) HoverHandler { id: hoverHandler } }Of course in this case the collapse / expand is performed by hovering and not clicking.
With a click I would simply go to a simple Text with a mouse area and a collapsed property
Text { property bool collapsed: true text: collapsed ? sourceData.text.slice(30) : sourceData.text MouseArea { anchors.fill: parent onClicked: collapsed = !collapsed } }Text and MouseArea seem to me a more suitable way to acheive this, but if you want a Button, Radio or Check, this would be basically similar to my second example. Yours to see.
so of course in this approach you will have your text sliced after 30 chars, yours to see how long you want it to be. The result will likely be cut right in the middle of a word, and you might want to cut after a certain number of words rather than a certain number of chars.
-
If you want only one cell to be expanded at a time (that is automatically collapsing the currently expanded cell when selecting another one) on a click, the RadioDelegate might be an interesting option to consider. And customize it in order to make disapear the round button (I don't really know how to call it) if you ever find this to be relevant.
And simply use the RadioDelegate's text property to display your text. -
The original post talks about TableView and not QTableView, which made me figure out QML.
However, a new QWindow ... QQuickWindow inherits QWindow while QWidget doesnt ...