Compilation error when using QBalloonTip private class in the project
-
I want to use QBallonTip to display a tooltip with a tail. As per this stack overflow answer, I can use or modify it but it is a private class meaning I have to be careful about it being moved elsewhere in future. I want to use this class because it solves my problem and I plan to modify it to make the tail point to a QPoint in the Mainwidow.
The Stack overflow answer mentions modifying the QBallonTip class and includes it directly in the source code. I tried to simply include in my project but I'm running into compilation errors before making any modifications.
I am currently getting "undefined reference to QBalloonTip class" error which as I understand means that the compiler cannot find the implementation of the class.
Now, the class is defined in the file qsystemtrayicon_p.h.
When I use QBalloonTip, qsystemtrayicon_p.h header at the following location is used. Also, I cannot respective cpp file there which I believe is causing the error:
C:\Qt\Qt5.9.0\5.9\mingw53_32\include\QtWidgets\5.9.0\QtWidgets\private\qsystemtrayicon_p.h
Here is the header mentioned in the stack overflow answer. Apparently, this location also has the source file in the same directory but is not picked up by the compiler:
C:\Qt\Qt5.9.0\5.9\Src\qtbase\src\widgets\util\qsystemtrayicon_p.h
What could be the best approach to resolve this issue?
-
Since QBallonTip is a private class it's not exported and therefore not visible from the outside.
-
Hi,
You have to explicitly state in your .pro file that you want to use the Qt widgets private API knowing that it may change completely or even disappear in the next version of Qt.
[edit]: not everything in the private implementation is exported and thus available to use.
-
Hi,
You have to explicitly state in your .pro file that you want to use the Qt widgets private API knowing that it may change completely or even disappear in the next version of Qt.
[edit]: not everything in the private implementation is exported and thus available to use.
@SGaist I have already done with QT += widgets-private.
Do I need to do anything else?
-
Again: QBallonTip is not exported. You can not create an instance of this class by yourself!
-
@faiszalkhan @Christian-Ehrlicher is correct, I missed the export part so it's indeed a class you cannot use.