[Solved] Disable context menu for particular hyperlink in QMessageBox
-
wrote on 22 Oct 2014, 10:19 last edited by
Hello.
I showing QMessagebox which contains some text and two hyperlinks. Qt automatically adds context menu for those hyperlinks with command "Copy link location". My goal is to disable appearance of context menu for first hyperlink and keep it work for second hyperlink. How to do it? Thanks.
Qt version = 5.2.1, OS = Windows 8.1
-
Hi,
It would be pretty convoluted to achieve what you want with QMessageBox. You should rather create your own dialog for that.
Note that your users may get confused as to why one link works and not the other.
-
wrote on 23 Oct 2014, 06:28 last edited by
Hello.
Thank you for answer. I got it. No easy solution here. Ok I will write here some information about my solution and mark thread as "[Solved]".The link which shouldn't work is internal link (link to window of the program), so it's textual representation doesn't have any sense for user.
-
If it doesn't have any sense for the user then why show it that way ?
-
wrote on 23 Oct 2014, 07:15 last edited by
Oops. Looks like I didn't explain it very well. In the code link looks like "<a href='specurl://window2'>window</a>". To make it work I use QDesktopServices::setUrlHandler. So the link itself is useful, but the text "specurl://window2" is useless, because it can't be used in the program or in any other program. This is the reason to disable ability to copy link to clipboard.
-
Didn't you create an url handler for "specurl"?
-
wrote on 24 Oct 2014, 03:56 last edited by
I did it. Url handler is the function, which name is passing to the function QDesktopServices::setUrlHandler. Right? Url handling works fine, I have no problem with it.
-
Ok, I see what misguided me.
Then again, I don't see any easy solution except making your own dialog
-
wrote on 24 Oct 2014, 10:08 last edited by
So be it :)
-
wrote on 28 Nov 2014, 06:09 last edited by
I managed to disable context menu using a trick. Message was splitted into paragraphs. 1st paragraph contains 1st hyperlink, 2nd paragraph contains 2nd hyperlink. Then I manually added 2nd paragraph into QMessageBox's layout as QLabel with disabled context menu.
-
wrote on 28 Nov 2014, 06:09 last edited by
I managed to disable context menu using a trick. Message was splitted into paragraphs. 1st paragraph contains 1st hyperlink, 2nd paragraph contains 2nd hyperlink. Then I manually added 2nd paragraph into QMessageBox's layout as QLabel with disabled context menu.
-
Sounds good, thanks for sharing your idea !
-
Sounds good, thanks for sharing your idea !