Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface)
-
Hi,
I'm quiet frustrated. Since a long time I try to install QT on an UBUNTU 18.04.3 Host cross compile for a raspberry3.
There are a lot of tipps and tutorials how to install the qt creator for cross compile and remote debugging for a raspberry but now works really for me.
I use a raspberry 3 where a LCD-display is connected via HDMI and SPI (for a touch pen). It runs a raspbian buster and the driver for the display.
The installation is qt 5.12.5 based on 5.13.1 and qt-creator 4.10.0.
The installation was fine and there where now errors during the installation.
But when I create a simple widget with some buttons (e.g. one push button and one radio butto) it handles only one button.
I get some errors when I run this widgetUnable 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). Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.
but I cannot find any solution for them.
This is the code for the widget:
mainwindow.cpp:#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { qDebug() << "Hallo Pushy!"; } void MainWindow::on_radioButton_clicked() { qDebug() << "Hallo Radio!"; }
and mainwindow.h
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } QT_END_NAMESPACE class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_pushButton_clicked(); void on_radioButton_clicked(); private: Ui::MainWindow *ui; }; #endif // MAINWINDOW_H
I'm sorry! sometimes I have the feeling sucessfull installing qt for creating widget for a raspberry never works and it's just a story like urban legends. Or does somebody really know a working tutorial or something?
It would be nice if I get an answerthanks in advance!
-
Hi
I understand your frustration. Cross compiling is often time consuming and hard to get working right.
I think you can just export the values
(in some .sh file to start app or in your profile so its always run)export QT_QPA_EGLFS_PHYSICAL_WIDTH=520
export QT_QPA_EGLFS_PHYSICAL_HEIGHT=326https://stackoverflow.com/questions/18518280/raspberry-pi-qt5-set-physical-screen-size
I liked this tutorial
https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/ -
-
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
it handles only one button
Does exact same application work properly on your host?
You're using auto-connect feature which is error-prone.I don't think the warning you see is related to your problem. You probably can ignore the warning.
-
@jsulm ,
yes I runned it on my host. Itworks perfectly!
Both buttons work.
When I start the widget on the raspberry from the command-line then it also shows this errors.
I think there went something wrong on the configuration during the installation.
I Installed it using almost this Tutorial link text.
I also installed qt on a raspberry and it also works without any problems.If you need I can insert the installationscripte for the raspberry and Linux host.
-
-
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
How cann I connect the signals manually to a slot?
Using connect(). https://doc.qt.io/qt-5/signalsandslots.html
"How do I prevent of auto-connection?" - do not use the naming convention (like on_pushButton_clicked()) - rename your slots to for example pushButtonClicked()
-
@jsulm ,
I use the qt-creator module to create form sheets.
Does it not work ? Must I setup everything without using the form file(=.ui)?
What is the problem? because I can create and run the widget on the host PC.
Do you think this is more a problem of the Touch-screen drivers?
Has anybody a idea? -
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
Does it not work ?
It does. What sometimes causes problems is the auto-connect feature - I was only talking about this and not whole Qt Designer (ui).
-
@jsulm ,
hi,
Thanks a lot for your answer!
Sorry for this delay but I was involved in an other project.
I use Qt5.10.1! and make a new widget.-
Here I open forms --> MainWindow.ui
-
Next I create two button
-
then I execute go to slot
-
this makes a new slot:
mainwindow.cpp
and mainwindow.h
Where must I modify the names? In both files mainwindow.cpp and mainwindow.h
-
-
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
Where must I modify the names?
This way you probably can't as designer generates the slot for you.
I create slots by myself, so can name them as I lake. -
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
You create your slots by yourself
You write the code by yourself.
If you renamed the slot then you have to connect signal and slot manually now:connect(ui->pushButton, &QPushButton::clicked, this, MainWindow::MyPushButtonClicked);
Please take a look at https://doc.qt.io/qt-5/signalsandslots.html
-
@jsulm
I'm really sorry but it's crazy.
When I go forward step by step you get again new errors.
I made it as you suggested but I get new problems:
I think I yuse this connect command in a wrong way:
When I compile it I get this errors:/home/kurt/qt-projekte/AsimpleWidget/mainwindow.cpp:9: error: invalid use of void expression connect(ui->MyPushButton, &QPushButton::clicked, this, MainWindow::MyPushButtonClicked());
and
/home/kurt/qt-projekte/AsimpleWidget/mainwindow.cpp:10: error: invalid use of void expression connect(ui->MyRadioButton,&QRadioButton::clicked, this, MainWindow::MyRadioButtonClicked());
I think this void makes some problems.
Thanks for a hint whats wrong -
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
MainWindow::MyRadioButtonClicked()
Hi
in the connect you should not have the ()
MainWindow::MyRadioButtonClicked**()**
when using the new syntax. ( the one with no SIGNAL and SLOT macros)connect(ui->MyRadioButton,&QRadioButton::clicked, this, MainWindow::MyRadioButtonClicked); // no () in the end
-
Hi @jsulm ,
I think it's like Sisyphean task because I f you solve one problem you get the next one.
Thank you for your patience. But I got the next problem:/home/kurt/qt-projekte/AsimpleWidget/mainwindow.cpp:9: error: no matching function for call to ‘MainWindow::connect(QPushButton*&, void (QAbstractButton::*)(bool), MainWindow* const, <unresolved overloaded function type>)’ connect(ui->MyPushButton, &QPushButton::clicked, this, MainWindow::MyPushButtonClicked);
and
/opt/qt5pi/sysroot/usr/local/qt5pi/include/QtCore/qobject.h:275: error: no type named ‘type’ in ‘struct std::enable_if<false, QMetaObject::Connection>’
Now seems to be something wrong in the sysroot?
-
@K-Str said in Has anyone ever got a widget running on a rpi3 with LCD-Display (HDMI and SPI-Interface):
connect(ui->MyPushButton, &QPushButton::clicked, this, MainWindow::MyPushButtonClicked);
Hi
You are missing a & ( sorry my bad, i missed it before)connect(ui->MyPushButton, &QPushButton::clicked, this, -->& MainWindow::MyPushButtonClicked);