Home > Software engineering >  How to call qt_sequence_no_mnemonics?
How to call qt_sequence_no_mnemonics?

Time:12-21

With regards to qt_sequence_no_mnemonics(), the qt documentation says "This function is not declared in any of Qt's header files. To use it in your application, declare the function prototype before calling it."

But what does that mean? I only see this function declared in a cpp file that is not distributed. How do I declare that function, so that I can call it?

When I call it, is it on an instance of QKeySequence? Is it somehow static? Can someone help me understand what is meant by that documentation?

File here: https://code.woboq.org/qt5/qtbase/src/gui/kernel/qkeysequence.cpp.html

edit 1: I tried removing every import of QKeySequence, and walling that off behind a new file that does this:

struct Configure
{
    Configure()
    {
//      Qt::qt_set_sequence_auto_mnemonic( false );
//      QKeySequence::qt_set_sequence_auto_mnemonic( false );
        qt_set_sequence_auto_mnemonic( false );
    }
};

Configure   configure;

But that did not result in the removal of the shortcut-conflicts created by the global menus. The MenuBar menus still have "mnemonics" defined, and they still break the application.

FYI - I am trying to modify KDevelop, not writing my own application. I can post links to KDevelop files, but I have made no other changes.

CodePudding user response:

You can can declare the function by putting this near the top of your .cpp file (maybe just after the #includes):

extern void qt_set_sequence_auto_mnemonic(bool);

... that will tell your compiler that the function exists, so that code later in that same .cpp file can call it without producing a compile-time error, e.g.:

int main(int argc, char ** argv)
{
   qt_set_sequence_auto_mnemonic(true);
   [...]
}
  • Related