![]() Registered Member ![]()
|
Hello.
I want to make use of KConfig in a shared library to provide full-featured (kiosk, cascading various config files...) config file suport. The problem is that the constructor of KConfig seems to make directly or indirectly use of qAppName(). I get the following error message on the console: QApplication::qAppName: Please instantiate the QApplication object first The library doesn't accept additional output. And I can't instanciate a QApplication or KApplication object because it is a library. (Linking a Qt or KDE program against such a library will crash because there may be only one QApplication object at runtime.) Is there a possibility to 1.) supress the console output or 2.) work around this console output?
urwald, proud to be a member of KDE forums since 2008-Oct.
|
![]() Administrator ![]()
|
You need to alter the testing application to create a Q/KApplication instance. It is not the responsibility of the libraries to create them, but they in virtually all cases require them.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
It's not an application, it's a library. Because it's a library, I can't create a Q/KApplication instance because it would interfer with the instance that is created by a program that uses the library and the application that links to the library would crash. So I need another way: Either suppress the output or some sort of workaround. By I have no idea...
urwald, proud to be a member of KDE forums since 2008-Oct.
|
![]() Administrator ![]()
|
You shouldn't be running the library directly. You should have a testing application to use it, and that should create a KApplication instance.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
Hm, you don't understand me.
I want to write a lib. The lib has to use KConfig. - When I create an instance of Q/KApplication in the lib, it will interfer with the instance that I create in the program that uses the lib. - When I don't create an instance of Q/KApplication in the lib, I will the the error message "QApplication::qAppName: Please instantiate the QApplication object first" independently if the application creates Q/KApplication or not. So, again, my question: Is there a possibility to 1.) supress the console output or 2.) work around this console output?
urwald, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
Finally, I've found a way to implement it differently. So this is SOLVED.
urwald, proud to be a member of KDE forums since 2008-Oct.
|
![]() Administrator ![]()
|
Ok..
That error should not have occurred, possibly because your code was being called before kApp.exec() was called.
KDE Sysadmin
[img]content/bcooksley_sig.png[/img] |
![]() Registered Member ![]()
|
Hm, I have found (and that works fine) that all of Qt's messages by modifying temporally the internal component for message output (see qInstallMsgHandler for details). That's a nice solution.
urwald, proud to be a member of KDE forums since 2008-Oct.
|
Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]