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. [Solved]QApplication static linkage and plugins
Forum Updated to NodeBB v4.3 + New Features

[Solved]QApplication static linkage and plugins

Scheduled Pinned Locked Moved General and Desktop
11 Posts 2 Posters 2.9k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    jpalbertini
    wrote on last edited by
    #1

    Hi everyone,

    I build a Main App/plugin application using qt 5.1 for multi platform purpose.

    In windows, the Main app is statically linked whereas the plugins are dynamically linked (the first one is a requirement, the second more of a choice :) )

    Up until now, everything worked fine.

    Now I want the plugin to be able to show some stuff (mostly configuration...) and everything is not working fine on windows. When I intend to show something i got a "QWidget: Must construct a QApplication before a QPaintDevice". after a little bit of research, i understand that everything relying on a UI must have a instance of QApplication running, so qApp should not be NULL, but it is with my plugins but not my main app.

    Anyone knows how to set/assign a QApplication ?

    thanks in advance :)

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      basically you have nothing to do other than creating an QApplication instance.

      But to get you right:
      Your main app is linked statically against all Qt libs. Only your plugin is loaded dynamically? And this plugin also uses Qt stuff?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jpalbertini
        wrote on last edited by
        #3

        thanks for your reply,

        if it is possible I prefer to not create a QApplication, but rather use the one from my main application if possible...

        But yes only my plugins are loaded dynamically and yes they use non-ui Qt stuff

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          [quote author="jpalbertini" date="1383577128"]
          But yes only my plugins are loaded dynamically and yes they use non-ui Qt stuff[/quote]
          So how do you link your plugin binary against Qt?
          And what does your plugin do exactly? Doesn't sound like it's non-ui stuff when a QPaintDevice is required...

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jpalbertini
            wrote on last edited by
            #5

            my plugins are dynamically linked against qt

            basically i got two plugin, one which sends arrays of data, the other one sends QImages

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              so this means your application runs with 2 different Qt binaries...

              You should have created a QApplication in your main app, right?

              I still don't know where you are missing the QPaintDevice...

              But nvertheless you shouldn't mix statically and dynamic linked binaries. Either way link all dynamically or statically. I would suggest you also link your "plugins statically":http://qt-project.org/doc/qt-4.8/plugins-howto.html#static-plugins.

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jpalbertini
                wrote on last edited by
                #7

                one thing I also forgot to mention is that I have another app, which is dynamically linked against Qt that work fine and plugins can send QImages directly without a problem.

                So my thoughts are that the QCoreApplication::self value is not pass correctly to the plugin with a statically linked app (the qApp macro is NULL)

                1 Reply Last reply
                0
                • raven-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by
                  #8

                  sure it is, when you link your plugin against the dynamically linked version of Qt wherein the QApplication object never gets initialized.

                  --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                  If you have a question please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jpalbertini
                    wrote on last edited by
                    #9

                    Is there a way that I assign it myself ? the self and init() are marked as private so my range of action is kinda limited, without having to rebuilding Qt with some sort of a setInstance method...

                    1 Reply Last reply
                    0
                    • raven-worxR Offline
                      raven-worxR Offline
                      raven-worx
                      Moderators
                      wrote on last edited by
                      #10

                      no ... and don't do it!
                      You do want to assign a object from a statically linked address space into a dynamically linked one...
                      Doing this you will probably run into another problem sooner or later.

                      And also that your application needs 2 Qt distributions doesn't make sense don't you think?

                      Link your plugins also statically and you should be fine.

                      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                      If you have a question please use the forum so others can benefit from the solution in the future

                      1 Reply Last reply
                      0
                      • J Offline
                        J Offline
                        jpalbertini
                        wrote on last edited by
                        #11

                        ok thanks i'll do that

                        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