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. Pass a class with private constructor via signal/slot

Pass a class with private constructor via signal/slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 722 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.
  • J Offline
    J Offline
    JSher
    wrote on last edited by
    #1

    Hello,

    I am using the library SimpleXlsx. I create a CWorkbook book; and add sheets and data to it. I then try to pass it via SIGNAL like so:

    emit sendBook(book);  
    
    SIGNAL:
    void sendBook(SimpleXlsx::CWorkbook);
    

    The problem is that I get a compiler error on the emit: 'calling a private constructor of class 'SimpleXlsx::CWorkbook'

    I cannot seem to find and documentation of passing classes with private constructors via SIGNAL.

    Thanks,
    --James

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Are you using the signal and slot in the same thread?
      If yes, you can try to change param type to (const SimpleXlsx::CWorkbook &) and see if it can work.

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

        @Bonnie

        Unfortunately I am passing to another thread

        --James

        B 1 Reply Last reply
        0
        • J JSher

          @Bonnie

          Unfortunately I am passing to another thread

          --James

          B Offline
          B Offline
          Bonnie
          wrote on last edited by
          #4

          @JSher I've checked the source code of SimpleXlsx::CWorkbook.

              private:
                  //Disable copy and assignment
                  CWorkbook( const CWorkbook & that );
                  CWorkbook & operator=( const CWorkbook & );
          

          The copy function is disabled.
          Then I don't think it is possible to send it accross threads.

          With queued connections, the parameters must be of types that are known to Qt's meta-object system, because Qt needs to copy the arguments to store them in an event behind the scenes.

          I think the only way to pass it through signal/slot is to use a pointer and you need to assure that the pointer can be accessed by another thread correctly.

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

            @Bonnie

            Ok thank you. I am in the process of just passing the data back to the UI where the Workbook can be created. I do not want to get into using pointers from threads:)

            Thanks

            --James

            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