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
Forum Updated to NodeBB v4.3 + New Features

[Solved] Disable context menu for particular hyperlink in QMessageBox

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 4.5k Views 1 Watching
  • 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on 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 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
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on 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 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
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on 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 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
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 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 last edited by
                  #9

                  So be it :)

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    YuriQ
                    wrote on 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 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
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 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
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 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