Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Crash when using QKeySequence as global constant

    General and Desktop
    2
    2
    72
    Loading More Posts
    • 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.
    • K
      Kerndog73 last edited by

      Following program crashes:

      #include <QtGui/qkeysequence.h>
      
      inline const QKeySequence my_key_sequence = Qt::CTRL + Qt::Key_E;
      inline const QKeySequence my_other_key_sequence = QKeySequence::Copy;
      
      int main() {}
      

      Why does it crash and how do I get around this?

      1 Reply Last reply Reply Quote 0
      • Christian Ehrlicher
        Christian Ehrlicher Lifetime Qt Champion last edited by

        @Kerndog73 said in Crash when using QKeySequence as global constant:

        Why does it crash and how do I get around this?

        It crashes because QKeySequence (like most other gui classes) need a QGuiApplication instance to work properly.
        Simply don't create any global static at all.

        Qt has to stay free or it will die.

        1 Reply Last reply Reply Quote 2
        • First post
          Last post