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. implementing tr() results in exception?

implementing tr() results in exception?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 594 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    Today I've been through a project replacing instances of "some text" with tr("some text"), the project builds with no warnings and no errors, however when I launch in the debugger I get an exception instantly:

    Debugger encountered an exception: Exception at 0x6a432132, code: 0xc0000005: read access at 0x0, flags0x0 (first chance)
    

    Execution is halted on Q_OBJECT below:

    class SendRDF : public QMainWindow {
    Q_OBJECT
    

    No other changes have been performed.

    Kind Regards,
    Sy

    jsulmJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      @jsulm , Yes, that was the first thing I tried, I'm reading through:
      https://doc.qt.io/qt-5/i18n-source-translation.html

      Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

      Q_DECLARE_TR_FUNCTIONS(SendRDF)
      

      It has a red underline, not sure if its available in Qt 5.9.2 ?

      In the class where the exception is raised there two statics initialisated:

      QString SendRDF::msstrAbort(tr("&Abort"));
      QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
      

      Could this be the cause?

      KroMignonK Offline
      KroMignonK Offline
      KroMignon
      wrote on last edited by
      #8

      @SPlatten said in implementing tr() results in exception?:

      In the class where the exception is raised there two statics initialisated:
      Could this be the cause?

      Yes, this is probably the error source.
      This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
      You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

      It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

      SPlattenS 1 Reply Last reply
      1
      • SPlattenS SPlatten

        Today I've been through a project replacing instances of "some text" with tr("some text"), the project builds with no warnings and no errors, however when I launch in the debugger I get an exception instantly:

        Debugger encountered an exception: Exception at 0x6a432132, code: 0xc0000005: read access at 0x0, flags0x0 (first chance)
        

        Execution is halted on Q_OBJECT below:

        class SendRDF : public QMainWindow {
        Q_OBJECT
        

        No other changes have been performed.

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @SPlatten Did you try complete clean rebuild?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        SPlattenS 1 Reply Last reply
        1
        • jsulmJ jsulm

          @SPlatten Did you try complete clean rebuild?

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #3

          @jsulm , Yes, that was the first thing I tried, I'm reading through:
          https://doc.qt.io/qt-5/i18n-source-translation.html

          Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

          Q_DECLARE_TR_FUNCTIONS(SendRDF)
          

          It has a red underline, not sure if its available in Qt 5.9.2 ?

          In the class where the exception is raised there two statics initialisated:

          QString SendRDF::msstrAbort(tr("&Abort"));
          QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
          

          Could this be the cause?

          Kind Regards,
          Sy

          jsulmJ KroMignonK 3 Replies Last reply
          0
          • SPlattenS SPlatten

            @jsulm , Yes, that was the first thing I tried, I'm reading through:
            https://doc.qt.io/qt-5/i18n-source-translation.html

            Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

            Q_DECLARE_TR_FUNCTIONS(SendRDF)
            

            It has a red underline, not sure if its available in Qt 5.9.2 ?

            In the class where the exception is raised there two statics initialisated:

            QString SendRDF::msstrAbort(tr("&Abort"));
            QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
            

            Could this be the cause?

            jsulmJ Online
            jsulmJ Online
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #4

            @SPlatten said in implementing tr() results in exception?:

            not sure if its available in Qt 5.9.2 ?

            The compiler would break with an error if the macro would not be defined.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            SPlattenS 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @jsulm , Yes, that was the first thing I tried, I'm reading through:
              https://doc.qt.io/qt-5/i18n-source-translation.html

              Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

              Q_DECLARE_TR_FUNCTIONS(SendRDF)
              

              It has a red underline, not sure if its available in Qt 5.9.2 ?

              In the class where the exception is raised there two statics initialisated:

              QString SendRDF::msstrAbort(tr("&Abort"));
              QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
              

              Could this be the cause?

              KroMignonK Offline
              KroMignonK Offline
              KroMignon
              wrote on last edited by
              #5

              @SPlatten said in implementing tr() results in exception?:

              Q_DECLARE_TR_FUNCTIONS(SendRDF)

              Why do you use this?
              SendRDF::tr() should be enough.

              It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

              SPlattenS 1 Reply Last reply
              0
              • jsulmJ jsulm

                @SPlatten said in implementing tr() results in exception?:

                not sure if its available in Qt 5.9.2 ?

                The compiler would break with an error if the macro would not be defined.

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #6

                @jsulm , edited original post whilst you were posting.

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • KroMignonK KroMignon

                  @SPlatten said in implementing tr() results in exception?:

                  Q_DECLARE_TR_FUNCTIONS(SendRDF)

                  Why do you use this?
                  SendRDF::tr() should be enough.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #7

                  @KroMignon , I don't it was something I was investigating after getting the error and reading the documentation.

                  Kind Regards,
                  Sy

                  1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @jsulm , Yes, that was the first thing I tried, I'm reading through:
                    https://doc.qt.io/qt-5/i18n-source-translation.html

                    Not sure if I have jumped the gun in building before the implementation is complete? I just tried to include:

                    Q_DECLARE_TR_FUNCTIONS(SendRDF)
                    

                    It has a red underline, not sure if its available in Qt 5.9.2 ?

                    In the class where the exception is raised there two statics initialisated:

                    QString SendRDF::msstrAbort(tr("&Abort"));
                    QString SendRDF::msstrTransferComplete(tr("&Transfer Complete"));
                    

                    Could this be the cause?

                    KroMignonK Offline
                    KroMignonK Offline
                    KroMignon
                    wrote on last edited by
                    #8

                    @SPlatten said in implementing tr() results in exception?:

                    In the class where the exception is raised there two statics initialisated:
                    Could this be the cause?

                    Yes, this is probably the error source.
                    This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
                    You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

                    It is an old maxim of mine that when you have excluded the impossible, whatever remains, however improbable, must be the truth. (Sherlock Holmes)

                    SPlattenS 1 Reply Last reply
                    1
                    • KroMignonK KroMignon

                      @SPlatten said in implementing tr() results in exception?:

                      In the class where the exception is raised there two statics initialisated:
                      Could this be the cause?

                      Yes, this is probably the error source.
                      This is will done before Q(Core|Gui)Application has been initialized, so there is not translator available.
                      You cannot do this like this, you have to initialize the static members after QApplication has been initialized.

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #9

                      @KroMignon , thank you, that makes sense.

                      Kind Regards,
                      Sy

                      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