How to disconnect QxtGlobalShortcut?
-
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
[[merged identical threads, Tobias]]
-
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
-
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 ? -
duplicate of http://qt-project.org/forums/viewthread/27574/
-
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
-
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
-
Hum...
Your function could be called several times and you didn't set shortcut to 0 after deleting it.
-
You're welcome !
Please update the thread's title to solved so other forum users may know that a solution has been found :)
-
Then run you application through a debugger, it should help you find the problem
No worry