Selectable Text from QListView
-
Just bumping the post up to hope someone can suggest a solution for this.
Havent still been able to figure out a way to implement text selection in listview items or make them span across multiple items in the view.
If anyone has any pointers even a small hint, would be very helpful. Thanks
Sorry about bumping the post. Just cant see another way of getting the thread some attention.
-
Sure,
here ya go "Image":http://img84.imageshack.us/img84/4474/chatselection.png
Example for this would be say any chat client.
I have each message of this Chat client in a listview item. My question is how do i make it selectable like shown in the picture.
-
Found another example for the same.
"Kadu":http://img690.imageshack.us/img690/192/chatmc.png
This I found in the QT Apps actually. seems it is possible just cant seem to figure out how it is done even in this application. Tried going through the source but not able to find exactly what allows his items painted via delegates to be selectable.
Maybe you guys can identify the section?
-
Nah nothing yet,
been checking this quite madly actually :)
Yeh textEdit wouldnt cut my requirement cos the current implementation say has chat messages that can contain buttons and stuff for eg (sending / receiving files)
Would probably need the editor of the delegate to draw a textEdit for each item where the text can be selected and use mousePositions from the View->Viewport to indicate to the delegate if the mouse was already selected when entering the current item to continue selection.
Just seems like a really long winded and not proper way to achieve what would be needed
-
Just to update on this.
I got selectable text sorted however I let go of the entire QListView scenario.
Went with a QWebView and using the DOM model as a substitute for the QListModel, I could generate QWebElements as desired and you can have interactive buttons and sorts as well via html / javascript and style them using CSS
As a QWebPage getting content selected is a dolly and this got my requirement satisfied.
If anyone has a similar requirement. Do Not Go With QListView.
Main Issue with QListView was even if you design editor widgets that would allow text selection and open these as persistentIndexes,
we still have problems when the selection goes from one widget to another as the first widget has mouseGrabbed and the second QModelIndex does not receive a MouseEnter event (while the left mouse button is pressed)
If you manage to release mouse based on the cusor position and on leaving widget, you still got to track which direction mouse enters the new widget to simulate a text selection on its child widgets.
On the whole, getting this sort of functionality could be possible from a QListView but not something that can be done without subclassing the entire world and managing every action which is not very efficient at all.
Just pick QWebView or something else that can give this functionality easier :)
-
This problem has just pop up in my work and I found your post.
My requirements are, in some way, simpler than yours. I just have to select the text from a QListView in the same way QLabel do. Do have any other insights about accomplishing this with QListView?
-
This problem has just pop up in my work and I found your post.
My requirements are, in some way, simpler than yours. I just have to select the text from a QListView in the same way QLabel do. Do have any other insights about accomplishing this with QListView?