Qt Forum

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

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Recources in static lib problem

    General and Desktop
    2
    10
    1786
    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.
    • A
      Anticross last edited by

      I've got an application. It uses class from static lib. In that class was reiplemented painEvent and it use some images which is in the resources of static lib. When I use class in apllication I have no image on screen and got the message "Image is a null image". What I'm doing wrong ?

      1 Reply Last reply Reply Quote 0
      • A
        Asperamanca last edited by

        The resources of a library cannot be loaded automatically. Load the resources using Q_INIT_RESOURCE.

        1 Reply Last reply Reply Quote 0
        • A
          Anticross last edited by

          bq. The resources of a library cannot be loaded automatically. Load the resources using Q_INIT_RESOURCE.

          I try it. But it doesn't help.

          1 Reply Last reply Reply Quote 0
          • A
            Anticross last edited by

            Here is some code in class of static lib:
            @ pressed.insert("ledsOff", QImage("qrc:/buttonImage/Resources/ButtonPressed.png"));
            pressed.insert("redLed", QImage("qrc:/buttonImage/Resources/ButtonPressed_redLed.png"));
            pressed.insert("greenLed", QImage("qrc:/buttonImage/Resources/ButtonPressed_greenLed.png"));
            pressed.insert("ledsOn", QImage("qrc:/buttonImage/Resources/ButtonPressed_greenRedLed.png"));@

            And in main file of application:
            @Q_INIT_RESOURCE(sxConsoleButtons);
            QApplication a(argc, argv);@

            I use this class in designer when promote one of the PushButtons to my class.

            1 Reply Last reply Reply Quote 0
            • A
              Asperamanca last edited by

              I believe you cannot create resources before the QApplication object in main() has been created. Try switching those two lines in your main.

              1 Reply Last reply Reply Quote 0
              • A
                Anticross last edited by

                bq. I believe you cannot create resources before the QApplication object in main() has been created. Try switching those two lines in your main.

                Nope. I tried - there is no effect.

                1 Reply Last reply Reply Quote 0
                • A
                  Asperamanca last edited by

                  Have you verified that you can get the resource with that name within the static library? The "qrc:/" looks strange to me.

                  1 Reply Last reply Reply Quote 0
                  • A
                    Anticross last edited by

                    I change it to this: @pressed.insert("ledsOff", QImage(":/buttonImage/Resources/ButtonPressed.png"));
                    pressed.insert("redLed", QImage(":/buttonImage/Resources/ButtonPressed_redLed.png"));
                    pressed.insert("greenLed", QImage(":/buttonImage/Resources/ButtonPressed_greenLed.png"));
                    pressed.insert("ledsOn", QImage(":/buttonImage/Resources/ButtonPressed_greenRedLed.png"));

                    unpressed.insert("ledsOff", QImage(":/buttonImage/Resources/ButtonUnpressed.png"));
                    unpressed.insert("redLed", QImage(":/buttonImage/Resources/ButtonUnpressed_redLed.png"));
                    unpressed.insert("greenLed",QImage(":/buttonImage/Resources/ButtonUnpressed_greenLed.png"));
                    unpressed.insert("ledsOn", QImage(":/buttonImage/Resources/ButtonUnpressed_greenRedLed.png"));@ but still can't get images. But if I use it without static lib it works fine. Maybe I need to do something else ? Some project settings in Visual Studio or any other ideas ?

                    1 Reply Last reply Reply Quote 0
                    • A
                      Asperamanca last edited by

                      sxConsoleButtons is exactly the name of your qrc file in the static lib?

                      Beyond that, I'm afraid I'm stumped. I have project both with MinGW and Visual Studio that use static libs and resources, and it works.

                      1 Reply Last reply Reply Quote 0
                      • A
                        Anticross last edited by

                        sxConsoleButtons.qrc is actually it's name;

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