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. Recources in static lib problem
QtWS25 Last Chance

Recources in static lib problem

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 2.2k 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.
  • A Offline
    A Offline
    Anticross
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Anticross
        wrote on last edited by
        #3

        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
        0
        • A Offline
          A Offline
          Anticross
          wrote on last edited by
          #4

          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
          0
          • A Offline
            A Offline
            Asperamanca
            wrote on last edited by
            #5

            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
            0
            • A Offline
              A Offline
              Anticross
              wrote on last edited by
              #6

              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
              0
              • A Offline
                A Offline
                Asperamanca
                wrote on last edited by
                #7

                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
                0
                • A Offline
                  A Offline
                  Anticross
                  wrote on last edited by
                  #8

                  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
                  0
                  • A Offline
                    A Offline
                    Asperamanca
                    wrote on last edited by
                    #9

                    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
                    0
                    • A Offline
                      A Offline
                      Anticross
                      wrote on last edited by
                      #10

                      sxConsoleButtons.qrc is actually it's name;

                      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