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