Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved] Disable context menu for particular hyperlink in QMessageBox

[Solved] Disable context menu for particular hyperlink in QMessageBox

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 4.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YuriQ
    wrote on 22 Oct 2014, 10:19 last edited by
    #1

    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

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 22 Oct 2014, 12:46 last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        YuriQ
        wrote on 23 Oct 2014, 06:28 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 23 Oct 2014, 07:00 last edited by
          #4

          If it doesn't have any sense for the user then why show it that way ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • Y Offline
            Y Offline
            YuriQ
            wrote on 23 Oct 2014, 07:15 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 23 Oct 2014, 23:05 last edited by
              #6

              Didn't you create an url handler for "specurl"?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • Y Offline
                Y Offline
                YuriQ
                wrote on 24 Oct 2014, 03:56 last edited by
                #7

                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.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 24 Oct 2014, 08:45 last edited by
                  #8

                  Ok, I see what misguided me.

                  Then again, I don't see any easy solution except making your own dialog

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    YuriQ
                    wrote on 24 Oct 2014, 10:08 last edited by
                    #9

                    So be it :)

                    1 Reply Last reply
                    0
                    • Y Offline
                      Y Offline
                      YuriQ
                      wrote on 28 Nov 2014, 06:09 last edited by
                      #10

                      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.

                      1 Reply Last reply
                      0
                      • Y Offline
                        Y Offline
                        YuriQ
                        wrote on 28 Nov 2014, 06:09 last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 29 Nov 2014, 00:24 last edited by
                          #12

                          Sounds good, thanks for sharing your idea !

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            SGaist
                            Lifetime Qt Champion
                            wrote on 29 Nov 2014, 00:24 last edited by
                            #13

                            Sounds good, thanks for sharing your idea !

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved