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. Some questions about QSharedMemory
Forum Updated to NodeBB v4.3 + New Features

Some questions about QSharedMemory

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 336 Views 2 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.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by Mihan
    #1

    Hi
    I want to use QSharedMemory instead of QtDBus between a plugin and main program.
    But I still confuse about that as follow:

    1. How to insert data into QSharedMemory after I create(128) (e.g.). Should I use memcpy to copy my data into QSharedMemory::data()?
    2. Is it necessary that put the data into QBuffer then put that QBuffer into QDataStream and copy QDataStream into the QSharedMemory finally?
    3. How can I put a struct into?

    Regards
    Mihan

    kshegunovK 1 Reply Last reply
    0
    • MihanM Mihan

      Hi
      I want to use QSharedMemory instead of QtDBus between a plugin and main program.
      But I still confuse about that as follow:

      1. How to insert data into QSharedMemory after I create(128) (e.g.). Should I use memcpy to copy my data into QSharedMemory::data()?
      2. Is it necessary that put the data into QBuffer then put that QBuffer into QDataStream and copy QDataStream into the QSharedMemory finally?
      3. How can I put a struct into?

      Regards
      Mihan

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @Mihan said in Some questions about QSharedMemory:

      I want to use QSharedMemory instead of QtDBus between a plugin and main program.

      Why on both counts? You have the plugin and the program in the same address space, why do you feel you need IPC primitives to begin with?

      Read and abide by the Qt Code of Conduct

      MihanM 1 Reply Last reply
      3
      • kshegunovK kshegunov

        @Mihan said in Some questions about QSharedMemory:

        I want to use QSharedMemory instead of QtDBus between a plugin and main program.

        Why on both counts? You have the plugin and the program in the same address space, why do you feel you need IPC primitives to begin with?

        MihanM Offline
        MihanM Offline
        Mihan
        wrote on last edited by Mihan
        #3

        @kshegunov
        I don't quite understand it. Maybe I misunderstand Qt Plugin.
        If I don't use QSharedMemory or QtDbus, how does the main program communicate with plugins?

        kshegunovK 1 Reply Last reply
        0
        • MihanM Mihan

          @kshegunov
          I don't quite understand it. Maybe I misunderstand Qt Plugin.
          If I don't use QSharedMemory or QtDbus, how does the main program communicate with plugins?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by
          #4

          @Mihan said in Some questions about QSharedMemory:

          I don't quite understand it. Maybe I misunderstand Qt Plugin.

          It seems so, yes.

          If I don't use QSharedMemory or QtDbus, how does the main program communicate with plugins?

          Well, the usual way. The plugin is loaded and as a dynamically loaded library lives in the same address space as the loading process. Thus the main program operates with it as any other component it itself provides. The plugin exposes an entry point object, from where the program can query the actual plugin and do stuff. There are real good examples in the docs, have you looked at them?

          Read and abide by the Qt Code of Conduct

          MihanM 1 Reply Last reply
          1
          • kshegunovK kshegunov

            @Mihan said in Some questions about QSharedMemory:

            I don't quite understand it. Maybe I misunderstand Qt Plugin.

            It seems so, yes.

            If I don't use QSharedMemory or QtDbus, how does the main program communicate with plugins?

            Well, the usual way. The plugin is loaded and as a dynamically loaded library lives in the same address space as the loading process. Thus the main program operates with it as any other component it itself provides. The plugin exposes an entry point object, from where the program can query the actual plugin and do stuff. There are real good examples in the docs, have you looked at them?

            MihanM Offline
            MihanM Offline
            Mihan
            wrote on last edited by
            #5

            @kshegunov NO, I just know how to make a plugin.

            Cus I create my input plugin in main.cpp by qputenv :

            qputenv("QT_IM_MODULE", QByteArray("Qt5Input"));
            

            but now I want to make a USB hotplug check, it also has json to name it, but I don't know how t use it.

            kshegunovK 1 Reply Last reply
            0
            • MihanM Mihan

              @kshegunov NO, I just know how to make a plugin.

              Cus I create my input plugin in main.cpp by qputenv :

              qputenv("QT_IM_MODULE", QByteArray("Qt5Input"));
              

              but now I want to make a USB hotplug check, it also has json to name it, but I don't know how t use it.

              kshegunovK Offline
              kshegunovK Offline
              kshegunov
              Moderators
              wrote on last edited by kshegunov
              #6

              @Mihan said in Some questions about QSharedMemory:

              NO, I just know how to make a plugin.
              Cus I create my input plugin in main.cpp by qputenv

              Setting an environment variable doesn't a plugin make.
              Depending on the type of plugin there's a base class you derive from (for generic ones it's QObject). Then you load the plugins into the main application (if it's an application plugin, if it's a Qt plugin it's loaded automatically).

              Read here: https://doc.qt.io/qt-5/plugins-howto.html
              And here: https://doc.qt.io/qt-5/qpluginloader.html

              And here are a couple of decent examples:
              https://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html
              https://doc.qt.io/qt-5/qtwidgets-tools-plugandpaint-app-example.html

              Read and abide by the Qt Code of Conduct

              MihanM 1 Reply Last reply
              4
              • kshegunovK kshegunov

                @Mihan said in Some questions about QSharedMemory:

                NO, I just know how to make a plugin.
                Cus I create my input plugin in main.cpp by qputenv

                Setting an environment variable doesn't a plugin make.
                Depending on the type of plugin there's a base class you derive from (for generic ones it's QObject). Then you load the plugins into the main application (if it's an application plugin, if it's a Qt plugin it's loaded automatically).

                Read here: https://doc.qt.io/qt-5/plugins-howto.html
                And here: https://doc.qt.io/qt-5/qpluginloader.html

                And here are a couple of decent examples:
                https://doc.qt.io/qt-5/qtwidgets-tools-echoplugin-example.html
                https://doc.qt.io/qt-5/qtwidgets-tools-plugandpaint-app-example.html

                MihanM Offline
                MihanM Offline
                Mihan
                wrote on last edited by
                #7

                Thanks @kshegunov
                I wil redo my plugin

                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