Qt (homepage, wiki) is een set programma`s die wij gebruiken om de grafische kant van onze Python programma`s te regelen.
- Widgets
|
Qt widgets zijn vergelijkbaar met Python modules.
|
- Qt Creator installatie
|
https://www.osradar.com/install-qtcreator-on-ubuntu-18-04/ Qt creator is de IDE van Qt. Het installeert ook Qt zelf. Enkel Qt
- Ubuntu installatie
- Voorbereiding
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt autoremove
- Installatie
sudo apt-get install qtcreator
sudo apt-get install qt5-default
sudo apt-get install qt5-doc
sudo apt-get install qt5-doc-html qtbase5-doc-html
sudo apt-get install qtbase5-examples
|
Qt & database.
QPSQL is het antwoord om te kunnen werken met een PostgressQL database.
Qt & sound.
QAudioInput class is het antwoord om te kunnen werken met sound. Enkel krijg ik het niet aan de praat. VB1
Qt & propuslsion.
Voor de aandrijving worden wielen met naafmotoren gebruikt.
Basically we need the following elements:
- Battery gauge
So we must create a table and create at least 1 record from which we can read. Develop an application that reads a file every 5 seconds. Kate tells us rather well. First create a new project of type widget. Or Qt SQL examples. Memory database not usable since several programs must be able to read or set in 1 record. Connecting to a database is f@%&îng complicated. Especially where to put which snippets of code. Grrr, reading.
- Android
I want to be able to make Android apps as well. It seems that some stuff is missing. Turns out that Qt has not yet been installed/configured entirely. Qt wants to configure a new project called dialcontrol. Then the project cannot be parsed since no kit has been set up yet. Menu Tools/Options/Built and run/Kits/Autodetected shows that a Kit is prepared but not entirely finished. Somehow I do not have the right compilers installed for Qt. 6 compilers are available in the select box with illustrious names like: Linux-ICC, MinGW, GCC, Clang, Custom, QCC. The difference is explained by Qt. Rather strange since GCC is installed. That runs but no compiler for Android. In Android options downloaded the Android SDK command line editor, not the entire studio. Turns out to be not enough. So now downloading the studio version. Makes no difference. The NDK installs ok.
- Installer
The first step is to install the installer. Go to download and download your version. I moved the download to my home directory. After making the graphical installer executable, I ran it by double clicking on it (*.run). In the process become a member and install the defaults. You can always install add-ons etc later. When finished you are able to open Qt creator. Qt can be installed by using the Ubuntu software center. However, this installs an old version which hardly works. BogoToBogo.
- OpenGL
To test for openGL use: glxinfo | grep version. In our case next step is: sudo apt-get install mesa-utils. Though it helps me one step further it turns out that I now have 1.4 installed = mesa 10.5.9. 1.45 seems highest. But the example Boxes is asking for OpenGL version 1.5 or higher is required to run this demo. The program will now exit.
- Joystick
A joystick is not default in Qt, but plib is supposed to be the solution. fluxrobotigs sfml example. QtGame library.
- SQLite
We need an "application file format", a file format used to persist application state to disk or to exchange information between programs. Qt comes with an SQLite that runs on any local machine. SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed database engine in the world. If you have Firefox then there is an add-on and you are up and running.
- Grafische toepassingen: Gtk versus Qt
|
Wij kiezen voor Qt omdat GTK onder Windows een probleem blijkt te zijn en ik wil dat de applicatie uiteindelijk ook onder Windows loopt. Het blijkt een probleem om recente versies van GTKop Windows te installeren. Alternatief? https://riverbankcomputing.com/news
- GTK Ubuntu
Gtk home (C++)
Gtk home for Python
Tutorial Gtk
Hulp bij menu
https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
https://python-gtk-3-tutorial.readthedocs.io/en/latest/layout.html
- GTK Windows 10
https://pygobject.readthedocs.io/en/latest/getting_started.html
Na installatie van de maintenance tool of door C:\msys64\mingw64.exe kom je in een command terminal. Doe daar: pacman -Suy. dat upgrade de boel. Vervolgens bet pacman -S mingw-w64-x86_64-gtk3 mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject pacman -S mingw-w64-x86_64-python3-gobject de boel invoegen. En de test gtk3-demo werkt ook, maar onze app niet. die kan module gi niet vinden.
|
- Python verbinden met Qt: PyQt5 versus PySide2
|
Wij kiezen PySide2 vanwege de vrijere licentie.
From a code perspective in Python, it makes no difference because the APIs are virtually identical.(verschillenoverzicht)
- PySide2
Qt for Python (PySide2) is a recent push by Qt the company to officially support Python. It`s offered under the LGPL and can thus often be used for free. Qt for Python homepage.
- PyQt5
PyQt (homepage) is mature but requires you to purchase a license for commercial projects.PyQt5 tutorial.
|
- Qt vs Eclipse
|
C++ is de standaard taal voor gaming. Voor het dashboard is dit dus de aangewezen taal. C++ kan worden geschreven en gebruikt in meerdere editors. Deze editors bieden veel meer dan enkel tekstbewerking. Link1: Qt vs Eclipse, Link2: Qt vs Eclipse. Al met al lijkt Qt de aangewezen weg.
- Instellingen robot
The cockpit is the place to drive the robot by wire (wiki). It is a computer on which several programs and add-ons can run at the same time. Test Bolderbot settings.
- Qt is een framework om een user interface te maken. Qt Creator lijkt een handige en leuke tool om in C++ programmas voor een robot te ontwikkelen. Het is vooral geschikt om programmas voor vele platforms te ontwikkelen.
- Eclipse lijkt zich hoofdzakelijk te richten op C++ en is ook een main tool voor Java.
|
- LEGACY PyQt5 installatie
|
LEGACY want we gebruiken PySide2.
Voor Python gebruiken we PyQt5 om de grafische user interface te maken. first programs.
- Installatie Ubuntu
PyQt5 installatie
- Voorbereiding
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt autoremove
- Installatie
pip3 install --user pyqt5
sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools
|
- LEGACY Qt & Joystick
|
Een joystick is niet standaard opgenomen in Qt. SDL wordt aangeraden om een joystick in Qt te integreren. SDLbasic werkt echter niet rechtstreeks. Het laat wel de naam van de joystick zien, maar verder houdt het op. Ook in SDL basic blijkt de gemakkelijkste weg om de file uit te lezen. Open "/dev/input/js0" for input as 1. Dat werkt automatisch en het werkt goed. Qt Joystick test.
|
//This is an include, so no parsing needed
$qry2 = ("SELECT onderdelen.*,
soortonderdeel.id
FROM onderdelen
JOIN soortonderdeel ON onderdelen.idsrtodd = soortonderdeel.id
WHERE onderdelen.partid = $idpart
;");
$result2 = pg_query($con1, $qry2);
$row4 = pg_fetch_array($result2); //Make the fields accesible
foreach( $row4 AS $key => $val ){
$$key = stripslashes( $val );
}
$jaar = substr($changeddate,0,4);
$maand = substr($changeddate,5,2);
$dag = substr($changeddate,8,2);
$lastupdate = ("$jaar $maand $dag");
$prtsrttxt = get_txt($con1, 26, 1, $idsrtodd);
$jaar = substr($createddate,0,4);
$maand = substr($createddate,5,2);
$dag = substr($createddate,8,2);
$create_stamp = ("$dag $maand $jaar");
//GENERAL INFO FOR EVERY USER **************************************************
echo (" ");
echo (""); //Header
$tmp = get_txt($con1, 9, $koekje[2], 3923); //Fieldname at screen
if ($koekje[3]=="1") { //If this user wants to translate then
echo ("$tmp"); //If desired
}else{ echo ("$tmp"); } //Else just show if no need to translate
if ($koekje[0]>0 and $koekje[3]>0){ //User is logged in and translates
echo (" (edit)");
}
echo ("Algemene informatie test | ");
if ($codetext) { //Code like KY-026 or NA-41
echo ("");
$tmp = get_txt($con1, 9, $koekje[2], 3739); //Fieldname at screen
if ($koekje[3]=="1") { //If this user wants to translate then
echo ("$tmp"); //Class for colour
}else{ //So you are not allowed to translate
echo $tmp; //Show screenname of this field in user language
} //End of If you want to translate this fieldname at screen
echo ("  | ");
if ($codelink) {
echo ("$codetext");
}else{
echo ("$codetext");
} //End of if ($pinoutlink)
echo (" | ");
} //End of if ($codetext)
$tmp = get_txt($con1, 9, $koekje[2], 3741); //Fieldname at screen
if ($prijseurinclbtw > 0){ //Show price indication
$prijs_formatted = number_format($prijseurinclbtw / 100, 2, ',', '.');
echo ("$tmp   | ");
echo ("");
if ($urlprijs){
echo ("€  $prijs_formatted");
}else{
echo ("€  $prijs_formatted");
} //End of if ($urlprijs > "")
echo (" | ");
} //End of if ($prijseurinclbtw > 0)
if ($sketchtext) { //Link to OWN SOFTWARE
$tmp = get_txt($con1, 9, $koekje[2], 3738); //Fieldname at screen
echo ("$tmp   | ");
if ($sketchlink) {
echo ("$sketchtext");
}else{
echo ("$sketchtext");
} //End of if ($sketchlink)
echo (" | ");
} //End of if ($sketchtext)
$tmp = get_txt($con1, 9, $koekje[2], 3744); //Fieldname at screen
if ($pinouttext) { //Pinout
echo ("$tmp   | ");
if ($pinoutlink) {
echo ("$pinouttext");
}else{
echo ("$pinouttext");
} //End of if ($pinoutlink)
echo (" | ");
}
$tmp = get_txt($con1, 9, 1, 3735); //Fieldname at screen
$tmp2 = get_txt($con1, 26, 1, $row4[16]); //Group name in its language
echo ("$tmp   | "); //MENU GROUP
echo ("");
echo ("$tmp2 | ");
if ($koekje[0]>0 and $koekje[3]>0){ //User is logged in and translates
$tmp = get_txt($con1, 9, $koekje[2], 3918); //Fieldname at screen LANGUAGE
if ($row4[26] == 1) {$imgname = "nederland.png";}
if ($row4[26] == 2) {$imgname = "deutschland.png";}
if ($row4[26] == 3) {$imgname = "uk.png";}
if ($row4[26] == 4) {$imgname = "france.png";}
echo ("$tmp | ");
echo ("");
echo (" | ");
$tmp = get_txt($con1, 9, $row4[27], 3919); //Fieldname at screen
$statuskey = get_status_key($con1, $status);
$tmp2 = get_txt($con1, 61, $koekje[2], $statuskey); //Fieldname at screen
echo ("$tmp   | "); //STATUS
echo ("$status $tmp2 | ");
}
$tmp = get_txt($con1, 9, 1, 3966); //Fieldname at screen
echo ("$tmp   | "); //LAST CHANGED
$tmp = substr($changeddate, 0, 10);
echo ("$tmp | ");
echo (" ");
return;
////////////////////////////////////////////////////////////////////////////////
function get_status_key($con, $num){
$qry = ("SELECT id FROM status WHERE nr = $num ;");
$result = pg_query($con, $qry);
$row = pg_fetch_array($result);
return ("$row[0]");
}
// LIST ALL SOFTWARE THAT WILL RUN OM THIS PART *****************************
// INCLUDED IN ALL ROBOTS TO CHECK THEIR DIRECTORY
$qry2=("SELECT tblsystext.txtname
, software.urlmain
, software.sftname
, software.sftid
, software.controller
FROM software
LEFT JOIN tblsystext ON software.controller = tblsystext.recordid
WHERE position(' $idpart ' in software.prtlst) > 0
AND software.rstid = 2
AND tblsystext.lanid = $koekje[2]
AND tblsystext.txlid = 19
ORDER BY sftname ASC
, controller ASC
;");
$result = pg_query($con1, $qry2);
if (pg_num_rows($result)>0) { //Only if at least 1 program exists
echo (' ');
echo (""); //Header
$tmp = get_txt($con1, 9, $koekje[2], 3922); //Fieldname at screen
if ($koekje[3]=="1") { //If this user wants to translate then
echo ("$tmp"); //If desired
}else{ echo ("$tmp"); } //Else just show if no need to translate
echo (" |
---|
");
while($col = pg_fetch_array($result)){
$col[0] = ("$col[0]");
echo (" ");
echo ("$col[2]   | ");
echo ("$col[0] | ");
if ($koekje[0] > 0 and $koekje[3]>0){ //User is logged in and translates
echo ("");
echo ("(Edit) | ");
}
echo (' ');
}
echo (' ');
}
?>
// LIST ALL ROBOTS THAT INCLUDE THIS PART ***********************************
// $idpart
// INCLUDED IN ALL ROBOTS TO CHECK THEIR DIRECTORY
$qry_bpp=("SELECT farmbotversie.id
, farmbotversie.part_list
, tblsystext.txtname
FROM farmbotversie
LEFT JOIN tblsystext ON farmbotversie.id = tblsystext.recordid
WHERE tblsystext.txlid = 27
AND tblsystext.lanid = $koekje[2]
ORDER BY tblsystext.txtname ASC
;");
$result_bpp = pg_query($con1, $qry_bpp);
$header = 0;
while($colbpp = pg_fetch_array($result_bpp)){ //Only if at least 1 robot exists
if(substr_count($colbpp[1], " $idpart ") > 0){
if ($header == 0) {
echo ("");
echo (""); //Header
$tmp = get_txt($con1, 9, $koekje[2], 3879); //Fieldname at screen
if ($koekje[3]=="1") { //If this user wants to translate then
echo ("$tmp"); //If desired
}else{ echo ("$tmp"); } //Else just show if no need to translate
echo (" | ");
$header++;
} //End of if ($header == 0)
echo ("");
echo ("$colbpp[2]");
//Show software van deze bot
$qry=("SELECT software_basedir
FROM farmbotversie
WHERE id = $colbpp[0];");
$result = pg_query($con1, $qry);
$col = pg_fetch_array ($result ,0);
$dir1 = "/var/www/html/robotigs/software/$col[0]";
$arr1 = glob($dir1, GLOB_ONLYDIR);
if (isset($arr1[0])){
$folder = $arr1[0];
$countertmp = 0;
echo ("");
foreach (scandir($folder, 1) as $filename) {
if ($filename<>"." AND $filename <>".."){
if ($countertmp == 0){
$countertmp++;
} //End of if ($countertmp == 0)
$tmp = "/";
$dir = substr($folder, 14) ."/";
$link = $tmp .$dir .$filename;
$showname = substr($filename, 0 ,-4);
echo ("- ");
echo "$showname";
echo ("
");
} //End of if ($filename<>"." AND $filename <>".."){
} //End of foreach (scandir($folder, 1) as $filename)
echo ("");
} //End of if (isset($arr1[0]))
echo (" | ");
}
}
if ($header > 0){
echo (" ");
}
?>
Warning: include(/var/www/html/robotigs/includes/wishlistperpart.php): Failed to open stream: No such file or directory in /var/www/html/robotigs/includes/parts_header.php on line 128
Warning: include(): Failed opening '/var/www/html/robotigs/includes/wishlistperpart.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/robotigs/includes/parts_header.php on line 128
| //Location:/robotigs/includes/ picts_show.php
// Requieres: $pict_list and several picture handling javascript routines
//*** FROM HERE ON THE PICTURE CORNER STARTS -----------------------------------
if ($pict_list){ //There are 1 or more pictures to be printed
echo ("");
$counter = 0;
$aantal = str_word_count($pict_list, 0, "0123456789");
$lijst = str_word_count($pict_list, 1, "0123456789");
while($counter < $aantal){
$pictkey = $lijst[$counter];
$qryy1 = ("SELECT *
FROM illustrations
WHERE ill_id = $pictkey
;");
$resulty1 = pg_query($con1, $qryy1);
while($row = pg_fetch_array($resulty1)){ //Fields accesible by their name
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
}
$image = ("/robotigs/documentatie/plaatjes/$ill_name");
$pictfull = str_replace('_small', '', $image); //Pictfull=biggest version
$alt = ("Just wait till your 57....");
$txtname = get_txt($con1, 18, $koekje[2], $ill_id); //Robot illustrations subtitles
echo ("");
echo (' ');
$nummer = $counter + 1;
$txtAfb = get_txt($con1, 9, $koekje[2], 3865); //Pic Afb
if ($koekje[0]>0 and $koekje[3]>0){ //User is logged in and translates
echo ("$txtAfb $nummer: ");
echo ("$txtname");
echo (" ");
echo ("Ontkoppelen ");
if ($counter==0){
echo ("Up ");
}else{
echo ("Up ");
}
if ($nummer == $aantal){
echo ("Down");
}else{
echo ("Down");
}
}else{ //Else of if Meaning the current useer is logged in
echo ("$txtAfb $nummer: $txtname");
}
echo (''); //End of this picture
$counter++; //Prepair for next picture
}
echo (' | '); //All pictures are printed
} //End of if there are 1 or more pictures to be printed ----------------------
?>