Lazarus
Programming => Widgetset => QT => Topic started by: Fred vS on August 15, 2011, 08:24:24 pm
-
Hello everybody. :)
I have a free DJ application compiled with Qt.
If Qt is not installed I want that the application shows a error message like : "Error, Qt libraries are not installed, please do a sudo apt-get install Qt".
But, of course, if Qt is not installed, message dialogs do not works... :(
Anybody have a idea how to show such a message and how to know that Qt is installed ?
Thanks.
-
If you try run your Qt-application or Lazarus itself without libQt4pas.so installed, then you have this output in console:
$ ./lazarus
./lazarus: error while loading shared libraries: libQt4Pas.so.5: cannot open shared object file: No such file or directory
This is common behaviour on Linux. Linux users usually know that they have to run it from console to see what's bad.
-
Hello Mr Blaazen and thanks for your answer...
Linux users usually know that they have to run it from console to see what's bad.
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?
-
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?
You can try LoadLibrary-ing a Qt lib (QtCore is enough maybe?), and check the return value.
-
Of course, but for helping Linux Dummies, is there a way to show a message dialog without Qt installed ?
Yes, but not using the LCL. You can use for example X11 in Linux. It is almost always installed, it could be safe. Your code could be something like this:
<delphi>
program blabla;
....
begin
lLib := LoadLibrary(...);
if lLib = nil then
begin
ShowX11MessageBox;
end;
end.
</delphi>
And you can implement the message box using X11. A initial code to get started: http://wiki.lazarus.freepascal.org/X11#A_window_with_a_message
In Windows you can use the Windows API. There is a API for showing message boxes, so it should be much easier.
-
@ Mr Blaazen, Leledumbo and Felipemdc
Thank you, gracias, obrigado...
I gonna test it... ;D
-
Another thing to notice. I think that this might be impossible, because afaik the link to libQt4Pas.so is static so the error message is from the operating system and your program doesn't even start executing. In that case it will be impossible to change how the operating system handles this kind of error.
-
Seems like a better idea is to use the distribution's packaging system and create .deb/.rpm/etc files where the Qt dependency is included.
Or create a launcher app that checks for qt and runs the main app if present.
-
@ BigChimp
Or create a launcher app that checks for qt
Ok, and how to do it :-[
Thanks
-
@ BigChimp
Or create a launcher app that checks for qt
Ok, and how to do it :-[
Thanks
I'd have a look at Leledumbo's & Felipe's posts: write an FPC program that uses LoadLibrary to load a core QT library. If that fails, show a message box using X11 code on Linux (or Win32 API or OSX Carbon/Cocoa...).
If it works, execute the main Qt program (using TProcess or whatever)...
Regards,
BigChimp
-
Let your user start the program by a script, the script calls the actual program if Qt is available and otherwise use the many ways available to send a system message. So check existence of the message program, if it fails try the next one.
notify-send -t 0 "Testing" "Hello there"
xmessage -button ok -center file - "Hello"
shutdown -k -t 0 now "Hello"