Important: Please read the Qt Code of Conduct -

Linked text in an application?

  • Hi
    I am going to use pyside for this, this is my first QT app. I have just looked at pyside and Qt and just made little tests with PyQT before I found PySide, not installed it yet. Need to know if this is possible first :)

    What I want to do is an application to use in a linux based PC and have the ability to port it to other platforms with not that much changes. (The last part is not really important to me)

    So to my questions...

    I want the user to be able to make a part of there text clickable as an link, underscored text working as a button. I want it to be done by a right mouse button menu. The marked text will be the link and used as a key in a dictionary to show what it is linked to.
    Is it possible to do that, make a part of the text underscored and work as a button?

    As I see it the user must be able to switch between edit and view mode to make the link clickable, what do I use to show a clickable text?

    I also want the user to have the ability to do the opposite, right click on the link and remove it but keeping the text. Would it be possible?

    And if the user removes the key from the dictionary it will trigger a function that searches through the text and removes the link corresponding with the dictionary key but keeps the text.
    Would it be possible to do that?

    Is there some example code for doing this with pyside?

    Can someone tell me what I need to read up on and point me in the right direction?

    Thanks in advanced.

  • Yes, you can use hyperlinks in the different widget that can display rich text. You can use QLabel for instance (see QLabel::linkActivated() and QLabel::linkHovered()), but a QTextBrowser can do it too (QTextBrowser::anchorClicked()).

    Seeing how you want to make the user edit the links, perhaps using QTextEdit and/or a QTextBrowser is the best place to start.

  • Thank you very much :D

Log in to reply