Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. How to disconnect QxtGlobalShortcut?

How to disconnect QxtGlobalShortcut?

Scheduled Pinned Locked Moved 3rd Party Software
12 Posts 2 Posters 3.6k 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.
  • C Offline
    C Offline
    cidhuang
    wrote on last edited by
    #2

    As title.
    I declare a class member,

    @ QxtGlobalShortcut* shortcut @

    then

    @
    shortcut = new QxtGlobalShortcut();
    connect(shortcut, SIGNAL(activated()), this, SLOT(shortcutCallBack()));
    shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));
    @

    And when I want to disconnect it, access shortcut make application crash.
    I can not delete shortcut, too. It crashes.

    I need to reset the global shortcut, please help me.

    Thanks,

    Cid

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #3

      Hi,

      Please don't multi-post your question.

      With only that code it's not really clear why you would have a crash.

      So a wild guess, are you sure shortcut is not a shadowed variable ?
      When you delete/disconnect your shortcut, are you sure it's valid ?

      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
        #4

        duplicate of http://qt-project.org/forums/viewthread/27574/

        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
        • C Offline
          C Offline
          cidhuang
          wrote on last edited by
          #5

          Sorry for multi-post.

          Actually, the program crash at the first line of

          @
          if(shortcut)
          delete shortcut;
          @

          This is what I mean access. Really strange.

          Thanks,

          Cid

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Again, making guesses:
            You're not creating your shortcut in the class constructor, so the pointer value is an address to a random block of memory.

            Initialize shortcut (and any other pointer class variable that are not allocated in the constructor) to 0

            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
            • C Offline
              C Offline
              cidhuang
              wrote on last edited by
              #7

              I do that in constructor.

              @
              shortcut = 0;
              @

              and then

              @
              shortcut = new QxtGlobalShortcut();
              connect(shortcut, SIGNAL(activated()), this, SLOT(shortcutCallBack()));
              shortcut->setShortcut(QKeySequence("Ctrl+Shift+F12"));
              @

              after construction, a UI event call a function, in that function is

              @
              if(shortcut)
              delete shortcut;
              @

              It's really weird, so I post here to see if there is any other possibility.

              Thanks,

              Cid

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                Hum...

                Your function could be called several times and you didn't set shortcut to 0 after deleting it.

                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
                • C Offline
                  C Offline
                  cidhuang
                  wrote on last edited by
                  #9

                  Good reminder.

                  Thank you SGaist.

                  Really appreciate.

                  Cid

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    You're welcome !

                    Please update the thread's title to solved so other forum users may know that a solution has been found :)

                    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
                    • C Offline
                      C Offline
                      cidhuang
                      wrote on last edited by
                      #11

                      QxtGlobalShortcut is good.

                      It's other problem.

                      Sorry to waste your time.

                      Cid

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on last edited by
                        #12

                        Then run you application through a debugger, it should help you find the problem

                        No worry

                        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