Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
only one QPushButton with QWidget works
-
Hello to all,
I got a lot of very helpfull information on thos forum. Thanks to all.
Now I have a problem creating a widget.
Here my settings:- lWidget size = 480x320
- I removed the following items: QMenuBar, QToolBar, QStatusBar
- I still have : QMainWindow and QWidget
- Then I created two PushButtons Shutdown and MotorOnOf
When I execute the programm it catches only the PushButton Shutdown
When I have a button on this position on the raspbian GUI I can get it.
What could be the problem?
Here the program files:
MainWindow.cpp#include "mainwindow.h" #include "ui_mainwindow.h" #include <QPushButton> #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_ShutdownButton_clicked() { qDebug() << "Shutown now"; } void MainWindow::on_MotorOnOffButton_clicked() { qDebug() << "engine on"; }
MainWindow.h:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_ShutdownButton_clicked(); void on_MotorOnOffButton_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
MainWindow.ui:
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>480</width> <height>320</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralWidget"> <widget class="QPushButton" name="MotorOnOffButton"> <property name="geometry"> <rect> <x>360</x> <y>270</y> <width>89</width> <height>25</height> </rect> </property> <property name="text"> <string>Engine off</string> </property> </widget> <widget class="QPushButton" name="ShutdownButton"> <property name="geometry"> <rect> <x>70</x> <y>230</y> <width>89</width> <height>25</height> </rect> </property> <property name="text"> <string>Shutdown</string> </property> </widget> </widget> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> <connections/> </ui>
-
Hi
Without code, its really hard to guess at anything.You can paste the code here. just use the code tag from the editor.
-
@mrjj yes!
I inserted the code now. See post above.
-
Hi,
Do you have any runtime warning about slots not connected ?
-
@SGaist thanks for your answer.
I'm in the hospital and will answer as soon as I'm at home.
Is this warning visible running it using the Qt debugger?
-
There's no Qt debugger as there is no Qt compiler.
As for the runtime warning, they are printed on stdout.
-
@SGaist
yes there are some warnings:16:15:13: Checking available ports... 16:15:13: Found 101 free ports. 16:15:13: Starting gdbserver --multi :10000... 16:15:13: Debugging starts SSH is enabled and the default password for the 'pi' user has not been changed. This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password. 1689 Listening on port 10000 Remote debugging from host 192.168.180.65 Process /opt/Teleskop/bin/Teleskop created; pid = 1707 Could not load shared library symbols for 3 libraries, e.g. /usr/local/qt5pi/lib/libQt5Widgets.so.5. Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"?Could not load shared library symbols for 3 libraries, e.g. /usr/local/qt5pi/plugins/platforms/libqeglfs.so.Use the "info sharedlibrary" command to see the complete listing. Do you need "set solib-search-path" or "set sysroot"? Could not load shared library symbols for /usr/local/qt5pi/plugins/egldeviceintegrations/libqeglfs-brcm-integration.so.Do you need "set solib-search-path" or "set sysroot"? Could not load shared library symbols for /usr/local/qt5pi/plugins/imageformats/libqgif.so.Do you need "set solib-search-path" or "set sysroot"? Could not load shared library symbols for /usr/local/qt5pi/plugins/imageformats/libqico.so.Do you need "set solib-search-path" or "set sysroot"? Could not load shared library symbols for /usr/local/qt5pi/plugins/imageformats/libqjpeg.so.Do you need "set solib-search-path" or "set sysroot"? Unable to query physical screen size, defaulting to 100 dpi.To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
Maybe there is a failure.
-
Are you running this application on a remote device ?
If so, you should rather make it run first on your desktop machine and then run on the device.
-
@SGaist
I added the Kit for Desktop Qt 5.12.3 GCC 64 Bit-
It doesn't work. This is the error:17:06:03: Running steps for project Teleskop... 17:06:03: Configuration unchanged, skipping qmake step. 17:06:03: Starting: "/usr/bin/make" -j4 g++ -Wl,-rpath,/home/kurt/Qt/5.12.3/gcc_64/lib -o Teleskop main.o mainwindow.o moc_mainwindow.o -L/home/kurt/Qt/5.12.3/gcc_64/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGL -lpthread /usr/bin/ld: cannot find -lGL Makefile:263: recipe for target 'Teleskop' failed collect2: error: ld returned 1 exit status make: *** [Teleskop] Error 1 17:06:03: The process "/usr/bin/make" exited with code 2. Error while building/deploying project Teleskop (kit: Desktop Qt 5.12.3 GCC 64bit) When executing step "Make" 17:06:03: Elapsed time: 00:00.
I think I have to add the module GL. Is this correct? But where can I find this?
-
The missing GL error has been asked about many times already, you have to install the OpenGL development package from your distribution.
-
@SGaist ,
thanks for this hint I will add the kit for Ubuntu again tomorrow.
-
@SGaist
Yes I try to run it remotely on a raspberry.
Now I have installed the kit for the host PC. Yes it works perfect on the host.
What can I do to make it working on a remote raspberry? I use /usr/bin/gdb-multiarch for debugging remotely on the raspberry. Is this ok
-
Do you mean that your application is working fine on your desktop and still not on your target ?
-
@SGaist yes
if the target is the linux host (ubuntu desktop) the application works fine.
If the target is the raspberry it does not work.
What about this info:Could not load shared library symbols for 3 libraries, e.g. /usr/local/qt5pi/lib/libQt5Widgets.so.5.
Is there something missing?
Maybe somebody knows more about this problem.
-
What do you get if you call ldd on that file ?
-
@SGaist , where must I run ldd?
On the linux host PC or on the raspberry?
-
@SGaist ;
I will check it tomorrow
-
@k-str said in only one QPushButton with QWidget works:
Sorry, I made a mistake
What do you mean with that ?
-
@SGaist ,
yesterday I had some trouble with my computer network and I couldn't write a post correcttly.
Here the output of lcc:
Do yoe need the output also when I run lcc on the on the Linux host?
-
Looks good. What is the exact error message you're getting when starting your application ?
-
@SGaist ,
there are no errors when I run the application. Only warnings during startup as I wrote eight days ago.
Now I install everything new because I have some big troubles with the network running a virtual machine (=Hyper-V). I install it now on oracles virtual box.
I will see what happens after this.
It's crazy!!
Now I have an other problem after a new installation:
It seems to be a configuration failure:
When I start the application I get a problem.
What means this? does it miss an egl module?Process /opt/TestWidget/bin/TestWidget created; pid = 2877 qt.qpa.egldeviceintegration: Failed to load EGL device integration "eglfs_brcm" EGL library doesn't support Emulator extensions
and a window appears
I find no real help in the internet.
I use a MPI3508 LCD HDMI display on my raspberry3.
Maybe my current configuration cannot handle it.
Please has somebody an answer?
-
Do you mean that you have that error in a virtual machine ?
-
@SGaist ,
no I think something went wrong during the installation.
What mmeans this:
Failed to load EGL device integration "eglfs_brcm"
-
It's getting a bit fuzzy here. You seem to have issues both with your desktop machine and RaspberryPi.
Can you do a small summary of what is going on and where exactly ?
-
@SGaist , hello to all;
I'm sorry for the delay, but I made some investigation.
It seems to have just a little problem:
When I start the application local on the terminal then I first have to writeexport DISPLAY:=0
Then it works with a warning
libEGL warning: DRI2: failed to authenticate
Is there a way to add this command
export DISPLAY=:0
automaticially before I run the application?
-
@k-str You can write a simple shell script which first sets the env variable and then calls your app and then use this script to start the app.
-
@jsulm ,
thanks for your answer!
Yes I know there was somthing like this but I have no Idea how such a script looks.
Where can I find an example? It should wor also for debugging
-
@k-str
Two lines in the script:export DISPLAY=:0 full-path-or-plain-name-of-your-executable
If you need it for debugging too, change second line to:
full-path-or-plain-name-of-your-debugger full-path-or-plain-name-of-your-executable
Assuming your mobile is like Linux (I know nothing about mobiles), if you go
chmod +x the-script
then
the-script
is ready to execute.Alternatively, and better if it works:
I do not know when your program needs that
DISPLAY
environment variable set, how early on after start up. If it is literally as soon as as it loads then you will have to set the environment variable before invocation. But if it's not, say, until you first try to create the UI, before that (before creating theQApplication
) you could use Qt'sqputenv()
to set that environment variable, e.g. perhaps if it is not already set to something so user can setDISPLAY
if needed but your code defaults it to:0
it it is not defined. Doing it this way, if possible, would get rid of the need to have a script wrapper.
-
@JonB ,
thanks for your answer,
Is it also possible to start a script where you can pass the full path application?
Maybe a script which gets the application in a environment variable or so. E.g ??full-path-of-appl??* is the environment variable:
ScriptMyGDB
export DISPLAY=:0 gdbserver ??*full-path-of-appl*??
this means I have to start the script MyGDB by Qt-creator
-
@k-str
Don't follow your question. In a script you can do whatever you could do from the command-line. If you mean: can a script access environment variables, or can a script examine and pass on arguments passed to it, the answer to both is yes.You need to look at the documentation of whatever shell you are using for its scripting syntax. If you're Linux the standard one these days is
bash
, I don't know if that applies to whatever mobile. In your question I wonder if you're asking if you can pass an argument to the script on the command line and then pass it on to yourgdbserver
? In which case inbash
script try:gdbserver "$1"
If it's in an envivironment variable:
gdbserver "$SOMEVARIABLE"
-
@JonB ,
this looks very good. I will try it tomorrow.
Thanks a lot!
-
Hi @JonB ,
thanks for your tip but I cannot find a way how to do this.
Is there a way to execute a program by Qt-Creator by running a bash-script on the target machine (=raspberry)?
It should look like :#!/bin/bash export DISPLAY=:0 ??run or debug** <*application*>??
Maybe this is a new topic?
-
@k-str
I don't know because I don't use Qt Creator! You should look at wherever it documents its command line arguments, maybe you goqt-creator project-pro-file
?Having said that, I would advise you again to consider what I have suggested about not having to use a separate script file and instead making your code use
qputenv()
to set theDISPLAY
environment variable very early, if it's not already set (useqgetetnv()
for that), if you can make that work. Your life will be easier for both development and release if you do not have a separate wrapper.
-
@k-str There is no need for this script work around when running in QtCreator: go to Projects/Build & Run/Run and add the DISPLAY variable there in "Run Environment".
-
@jsulm ,
thanks, this sounds quiet easy! But I cannot find the point "Run Environment" where I can insert DISPLAY=:0.
See screenshot:
-
@k-str
I don't use Qt Creator, but I think you need to scroll down on that dialog on the right, did you not try that?
-
@k-str Scroll down...
-
@jsulm, hi to all,
I'm sorry, but I think I made some failures.
I checked everything and I think the problem is the LCD hardware.
I use one- QUIMAT 3.5"
- HDMI Display-B
- 480x320 Dots V1.2
- type MPI3508
- pen interface SPI
Maybe this cannot handle EGL mode.
Which plugin should I use for this LCD display?
I configered xcb but this is not ok. See below.
Now I installed Qt completely new using this instructions:
[https://wiki.qt.io/RaspberryPi2EGLFS]
and also some modifications from here;
[https://forum.qt.io/topic/83700/raspberry-pi-3-compile-with-x11-eglf-not-wanted]
The configuration command is:./configure -release -no-eglfs -qt-xcb -xcb -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- -sysroot ~/raspi/sysroot -opensource -confirm-license -make libs -prefix /usr/local/qt5pi -extprefix ~/raspi/qt5pi -hostprefix ~/raspi/qt5 -v -no-use-gold-linker
But I still get errors
qt.qpa.plugin: Could not find the Qt platform plugin "eglfs" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.
Are there instructions how to configure xcb or linuxfb or one of the above mentioned plugins
-
Hello,
I give up to install Qt Creator for remote development. It's like "Sisyphean task".
Now I installed Qt on my Raspberry and here I try to do my work.
I use the RemoteDesktop.
It seems it works for me.
Thanks a lot to all helpers.