Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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 widget

    
    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).
    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 answer

    thanks in advance!


  • Lifetime Qt Champion

    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=326

    https://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/



  • @mrjj Thanks for your answer,
    I'm sorry, it does not solve my problem.
    When I make there is sitll only one button active, the second has ignored and I get this Error:

    Attribute Qt::AA_ShareOpenGLContexts must be set before QCoreApplication is created.
    

  • Lifetime Qt Champion

    @K-Str Can you show your main.cpp file?



  • @jsulm
    Hello thanks for your answer,
    Here you will find the main.cpp code:

    #include "mainwindow.h"
    
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
        return a.exec();
    }
    

  • Lifetime Qt Champion

    @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.


  • Lifetime Qt Champion

    @K-Str I really don't know why this happens. Alternative approach would be to not to use auto-connect feature (it is error-probe anyway). Instead give your slots a bit different names and connect them manually with signals.



  • @jsulm Thanks your answer.
    I will try it.
    But

      1. How cann I connect the signals manually to a slot?
      1. How do I prevent of auto-connection?

    Could you give me a hint how to do it?


  • Lifetime Qt Champion

    @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?


  • Lifetime Qt Champion

    @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
      Screenshot from 2019-11-15 12-32-13.png

    • Next I create two button
      Screenshot from 2019-11-15 12-36-36.png

    • then I execute go to slot
      Screenshot from 2019-11-15 12-37-48.png

    • this makes a new slot:
      mainwindow.cpp
      Screenshot from 2019-11-15 12-40-32.png
      and mainwindow.h
      Screenshot from 2019-11-15 12-40-54.png
      Where must I modify the names? In both files mainwindow.cpp and mainwindow.h


  • Lifetime Qt Champion

    @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.



  • @jsulm ,
    hi,
    I just renamed it as follows:
    mainWindow.cpp
    Screenshot from 2019-11-15 12-56-56.png
    and mainwindow.h
    Screenshot from 2019-11-15 12-53-09.png
    It still doesn't work.
    It is frustrating!
    Was here something wrong?
    What does it mean "You create your slots by yourself"?


  • Lifetime Qt Champion

    @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:
    Screenshot from 2019-11-15 17-09-52.png
    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


  • Lifetime Qt Champion

    @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?


  • Lifetime Qt Champion

    @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);



  • Hi @jsulm ,
    thank you very much for your assistance!
    Now I can compile it without any failures!
    I think this is a problem with qts touch screen drivers for the raspberry.
    Maybe the system does not forward any signal from the touch screen.
    It's funny because it works if I use on the pure system. I can make everything.
    It works also If I create a widget using qt IDE on raspberry itself.
    But it does not work if I try to cross compile and ruining remotely.
    Has anybody an idea whats happened?
    Thanks to everybody in advance for any help.


Log in to reply