Results 1 to 2 of 2

Thread: HTML and *clickable links* inside a QListView?

  1. #1
    Join Date
    Nov 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question HTML and *clickable links* inside a QListView?

    Shortest version: How do I get clickable links to work inside a QListView? I would like to receive a signal when the user clicks such a link.

    Longer version + context:

    I have a data model which represents lines of data like:

    timestamp | source | text

    New items are being added periodically (and ideally old ones removed). The problem is that text is HTML and contains links (not necessarily external http://) which I want to trap. (Just rendering the HTML is no problem as I can do that with paint() in a custom delegate. But it needs to be *interactive*.)

    Currently I have resigned myself to using a QTextBrowser where I just append each line to (and never remove), but I consider this far from optimal because then I have to do formatting of the line itself, which I can't really get right, mix the elements, etc.

    Is there a better way? Ideally, let's say I want QLabels to represent the "text" column, I'd like QListView to only keep a small number of QLabels around (the number that will fit inside its frame), and set their text as the user scrolls (smoothly), doing all the layout / sizing magic etc. for me so I don't have to get a head ache about doing all this myself...

    For lets say I have a many thousand such lines, then I don't want many thousand individual QLabels (where 99% will be hidden anyway).

    I have looked at setIndexWidget() of views, but I don't think that was meant for something like this? Basically I rather want a setColumnRepresentationWidget()...? Or for data() of the model to be able to return a QWidget instead of a string when it comes to DisplayRole?

    I spent all of yesterday googling for this and I asked on IRC, but haven't gotten anything. I found people rendering widgets inside tree views and list views, but they were static non-interactive... If there already are any examples of this behavior or if my understanding is funtamentally flawed I appreciate any input.

    Oh, and I am using Python and not C++, but I'm not sure if that matters. I know C++ too.

  2. #2
    Join Date
    Nov 2008
    Location
    Padova - Italy
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: HTML and *clickable links* inside a QListView?

    Hi, this is not an answer to your question, but another question.
    I have been using Qt for the last two weeks so I'm really a newbie.
    Can you explain me how do you render HTML in a QListView? I really need it but I can't find how to do it.
    Thank you.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.