qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file
-
I am not experienced with QT and do not know detail in and outs of how it works, but I need to make a simplish GUI for my raspberry pi zero application, using QT. Please excuse any wrong usage of terminology, or if I have misunderstood something basic
I have built a cross compiler for my raspberry pi zero board in an Ubuntu 20.04 VM, following the instructions from here: https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/
However, I have to point out that I have not done steps 1,2 and the rsync part mentioned in step 7 from that page. Instead of steps 1 and 2, I have installed QT in raspberry pi using
$sudo apt-get install qt5-default $sudo apt-get install qtdeclarative5-dev
then I followed steps 2 to 7 upto make install but did not do the rsync part, and installed qtcreator using instructions in step 8. This much is enough to allow me to compile basic "hello world" like GUI applications (for example, the type shown here: https://www.linux.org/threads/c-tutorial-create-qt-applications-without-qtcreator.18409/)
I need some way of displaying a simple local html file in my GUI applications, so I installed
$sudo apt-get install libqt5webkit5-dev
in raspberry pi zero. I can display local html files in the applications that I code and compile directly on the raspberry pi zero, which is good enough for my need
However I would like to be able to cross compile code using libqt5webkit5-dev for the pi zero board in the Ubuntu VM as well. After installing libqt5webkit5-dev in the pi zero I have performed the 4 rsync operations mentioned in step 4 of the cross compiler tutorial mentioned above. The rsync operations seem to have been successful since
sudo find / -name "QtWebKitWidgets"
now shows me
/home/ubuntu2004/raspi/sysroot/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets /home/ubuntu2004/raspi/sysroot/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets/QtWebKitWidgets /home/ubuntu2004/raspberrypi/rootfs/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets /home/ubuntu2004/raspberrypi/rootfs/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets/QtWebKitWidgets
(Note: raspi/sysroot is the folder associated with the Qt cross compiler, please ignore the other /raspberrypi/rootfs folder)
But if I copy over the basic GUI html viewer project from the pi zero board over to the Ubuntu VM, when I run
qmake projectname.pro
I get the following error:
Info: creating stash file /home/ubuntu2004/myfolder/NeosQt4/.qmake.stash Project ERROR: Unknown module(s) in QT: webkitwidgets
It looks like qmake does not recognize "webkitwidgets". Do I need to rebuild QT (steps 6-7)? Last time I had to do it it took me 5 hours so I would like to avoid it if possible, but if that's the only way to do this please do let me know. I just don't want to start the process and find out later it wasn't relevant. If I don't need to rebuild QT, or if it's not something related to my problem, how can I get qmake to recognise "webkitwidgets"?
These are the source code files I am using for my test. They are all in the same folder (NeosQt4). Normally I would build it has qmake -project and qmake NeosQt4.pro, followed by make.
main.cpp
#include <QtWidgets> #include "mainwidget.h" int main(int argc, char *argv[]) { // Creates an instance of QApplication QApplication a(argc, argv); // This is our MainWidget class containing our GUI and functionality MainWidget w; w.show(); // Show main window // run the application and return execs() return value/code return a.exec(); }
MainWidget.cpp
#include <QtWidgets> #include "mainwidget.h" // Constructor for main window MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { button_ = new QPushButton(tr("Push Me!")); textBrowser_ = new QTextBrowser(); scene_ = new QGraphicsScene(); view_ = new QGraphicsView(scene_); item_ = new QGraphicsPixmapItem(QPixmap("1.jpg")); // item = new QGraphicsPixmapItem(QPixmap("1.png")); scene_->addItem(item_); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(button_,0,0); mainLayout->addWidget(textBrowser_,1,0); // mainLayout->addWidget(webview_,0,1); webview_ = new QWebView(parent); // webview_->load(QUrl("https://www.google.com")); // slow but works webview_->load(QUrl::fromLocalFile(QFileInfo("news.html").absoluteFilePath())); // this one works webview_->show(); setLayout(mainLayout); setWindowTitle(tr("Connecting buttons to processes..")); connect(button_, SIGNAL(released()), this, SLOT(onButtonReleased())); } // Destructor MainWidget::~MainWidget() { delete button_; delete textBrowser_; } // Handler for button click void MainWidget::onButtonReleased() { // clear the text in the textBrowser and start the process textBrowser_->clear(); textBrowser_->setText(tr("Button pressed")); view_->show(); }
mainwidget.h
#ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> #include <QGraphicsScene> #include <QtWebKitWidgets> class QPushButton; class QTextBrowser; class QGraphicsScene; class QGraphicsView; class QGraphicsPixmapItem; // class QPixmap; class QtWebKitWidgets; // This is the declaration of our MainWidget class // The definition/implementation is in mainwidget.cpp class MainWidget : public QWidget { Q_OBJECT public: explicit MainWidget(QWidget *parent = 0); //Constructor ~MainWidget(); // Destructor private slots: void onButtonReleased(); // Handler for button presses private: QPushButton* button_; QTextBrowser* textBrowser_; QGraphicsScene* scene_; QGraphicsView* view_; QGraphicsPixmapItem* item_; // QtWebKitWidgets* webview_; QWebView* webview_; }; #endif // MAINWIDGET_H
NeosQt4.pro (this compiles when used directly on the raspberry pi zero)
###################################################################### # Automatically generated by qmake (3.1) Fri Oct 15 11:56:05 2021 ###################################################################### TEMPLATE = app TARGET = NeosQt4 INCLUDEPATH += . QT += webkitwidgets # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input HEADERS += mainwidget.h SOURCES += main.cpp MainWidget.cpp
For another cmake/gcc cross compiler I am working on, doing an rsync after installing a new library in the pi zero, was enough to start cross compiling C++ programs using that new library. I assumed things would be similar with QT after installing
libqt5webkit5-dev
in the pi zero board, but doesn't seem to be the case. Please let me know if I am going about this the wrong way.
-
I am not experienced with QT and do not know detail in and outs of how it works, but I need to make a simplish GUI for my raspberry pi zero application, using QT. Please excuse any wrong usage of terminology, or if I have misunderstood something basic
I have built a cross compiler for my raspberry pi zero board in an Ubuntu 20.04 VM, following the instructions from here: https://mechatronicsblog.com/cross-compile-and-deploy-qt-5-12-for-raspberry-pi/
However, I have to point out that I have not done steps 1,2 and the rsync part mentioned in step 7 from that page. Instead of steps 1 and 2, I have installed QT in raspberry pi using
$sudo apt-get install qt5-default $sudo apt-get install qtdeclarative5-dev
then I followed steps 2 to 7 upto make install but did not do the rsync part, and installed qtcreator using instructions in step 8. This much is enough to allow me to compile basic "hello world" like GUI applications (for example, the type shown here: https://www.linux.org/threads/c-tutorial-create-qt-applications-without-qtcreator.18409/)
I need some way of displaying a simple local html file in my GUI applications, so I installed
$sudo apt-get install libqt5webkit5-dev
in raspberry pi zero. I can display local html files in the applications that I code and compile directly on the raspberry pi zero, which is good enough for my need
However I would like to be able to cross compile code using libqt5webkit5-dev for the pi zero board in the Ubuntu VM as well. After installing libqt5webkit5-dev in the pi zero I have performed the 4 rsync operations mentioned in step 4 of the cross compiler tutorial mentioned above. The rsync operations seem to have been successful since
sudo find / -name "QtWebKitWidgets"
now shows me
/home/ubuntu2004/raspi/sysroot/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets /home/ubuntu2004/raspi/sysroot/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets/QtWebKitWidgets /home/ubuntu2004/raspberrypi/rootfs/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets /home/ubuntu2004/raspberrypi/rootfs/usr/include/arm-linux-gnueabihf/qt5/QtWebKitWidgets/QtWebKitWidgets
(Note: raspi/sysroot is the folder associated with the Qt cross compiler, please ignore the other /raspberrypi/rootfs folder)
But if I copy over the basic GUI html viewer project from the pi zero board over to the Ubuntu VM, when I run
qmake projectname.pro
I get the following error:
Info: creating stash file /home/ubuntu2004/myfolder/NeosQt4/.qmake.stash Project ERROR: Unknown module(s) in QT: webkitwidgets
It looks like qmake does not recognize "webkitwidgets". Do I need to rebuild QT (steps 6-7)? Last time I had to do it it took me 5 hours so I would like to avoid it if possible, but if that's the only way to do this please do let me know. I just don't want to start the process and find out later it wasn't relevant. If I don't need to rebuild QT, or if it's not something related to my problem, how can I get qmake to recognise "webkitwidgets"?
These are the source code files I am using for my test. They are all in the same folder (NeosQt4). Normally I would build it has qmake -project and qmake NeosQt4.pro, followed by make.
main.cpp
#include <QtWidgets> #include "mainwidget.h" int main(int argc, char *argv[]) { // Creates an instance of QApplication QApplication a(argc, argv); // This is our MainWidget class containing our GUI and functionality MainWidget w; w.show(); // Show main window // run the application and return execs() return value/code return a.exec(); }
MainWidget.cpp
#include <QtWidgets> #include "mainwidget.h" // Constructor for main window MainWidget::MainWidget(QWidget *parent) : QWidget(parent) { button_ = new QPushButton(tr("Push Me!")); textBrowser_ = new QTextBrowser(); scene_ = new QGraphicsScene(); view_ = new QGraphicsView(scene_); item_ = new QGraphicsPixmapItem(QPixmap("1.jpg")); // item = new QGraphicsPixmapItem(QPixmap("1.png")); scene_->addItem(item_); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(button_,0,0); mainLayout->addWidget(textBrowser_,1,0); // mainLayout->addWidget(webview_,0,1); webview_ = new QWebView(parent); // webview_->load(QUrl("https://www.google.com")); // slow but works webview_->load(QUrl::fromLocalFile(QFileInfo("news.html").absoluteFilePath())); // this one works webview_->show(); setLayout(mainLayout); setWindowTitle(tr("Connecting buttons to processes..")); connect(button_, SIGNAL(released()), this, SLOT(onButtonReleased())); } // Destructor MainWidget::~MainWidget() { delete button_; delete textBrowser_; } // Handler for button click void MainWidget::onButtonReleased() { // clear the text in the textBrowser and start the process textBrowser_->clear(); textBrowser_->setText(tr("Button pressed")); view_->show(); }
mainwidget.h
#ifndef MAINWIDGET_H #define MAINWIDGET_H #include <QWidget> #include <QGraphicsScene> #include <QtWebKitWidgets> class QPushButton; class QTextBrowser; class QGraphicsScene; class QGraphicsView; class QGraphicsPixmapItem; // class QPixmap; class QtWebKitWidgets; // This is the declaration of our MainWidget class // The definition/implementation is in mainwidget.cpp class MainWidget : public QWidget { Q_OBJECT public: explicit MainWidget(QWidget *parent = 0); //Constructor ~MainWidget(); // Destructor private slots: void onButtonReleased(); // Handler for button presses private: QPushButton* button_; QTextBrowser* textBrowser_; QGraphicsScene* scene_; QGraphicsView* view_; QGraphicsPixmapItem* item_; // QtWebKitWidgets* webview_; QWebView* webview_; }; #endif // MAINWIDGET_H
NeosQt4.pro (this compiles when used directly on the raspberry pi zero)
###################################################################### # Automatically generated by qmake (3.1) Fri Oct 15 11:56:05 2021 ###################################################################### TEMPLATE = app TARGET = NeosQt4 INCLUDEPATH += . QT += webkitwidgets # The following define makes your compiler warn you if you use any # feature of Qt which has been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input HEADERS += mainwidget.h SOURCES += main.cpp MainWidget.cpp
For another cmake/gcc cross compiler I am working on, doing an rsync after installing a new library in the pi zero, was enough to start cross compiling C++ programs using that new library. I assumed things would be similar with QT after installing
libqt5webkit5-dev
in the pi zero board, but doesn't seem to be the case. Please let me know if I am going about this the wrong way.
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
$sudo apt-get install qt5-default
$sudo apt-get install qtdeclarative5-devThis is unrelated to your cross compiled Qt. I think you have to also cross compile qtdeclarative module.
-
But cross compiling is working (at least using the basic widgets (buttons, textboxes, etc) I need) as long as I don't use the webkitwidgets. I don't really have any idea about how to cross compile qtdeclarative module. Do you think I won't have to rebuild QT? That's the step I would like to avoid, mainly because it took a lot of time.
-
But cross compiling is working (at least using the basic widgets (buttons, textboxes, etc) I need) as long as I don't use the webkitwidgets. I don't really have any idea about how to cross compile qtdeclarative module. Do you think I won't have to rebuild QT? That's the step I would like to avoid, mainly because it took a lot of time.
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
Do you think I won't have to rebuild QT?
No, you do not have to rebuild everything (and I did not write that). You just need to build the missing module...
-
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
$sudo apt-get install qt5-default
$sudo apt-get install qtdeclarative5-devThis is unrelated to your cross compiled Qt. I think you have to also cross compile qtdeclarative module.
@jsulm said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
$sudo apt-get install qt5-default
$sudo apt-get install qtdeclarative5-devThis is unrelated to your cross compiled Qt. I think you have to also cross compile qtdeclarative module.
How do I cross compile just the qtdeclarative module? Is there a tutorial for that?
-
@jsulm said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
$sudo apt-get install qt5-default
$sudo apt-get install qtdeclarative5-devThis is unrelated to your cross compiled Qt. I think you have to also cross compile qtdeclarative module.
How do I cross compile just the qtdeclarative module? Is there a tutorial for that?
-
@mahaju Go to the qtdeclarative folder in Qt source code tree. Then call qmake from your cross compiled Qt, then call "make" and then "make install".
@jsulm said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
@mahaju Go to the qtdeclarative folder in Qt source code tree. Then call qmake from your cross compiled Qt, then call "make" and then "make install".
I did all this, but if I try to build my html viewer application, I still get the
Project ERROR: Unknown module(s) in QT: webkitwidgets
when I do qmake NeosQt4.pro
-
How does qmake decide which words it recognises and which ones it doesn't? For example right now it recognises "widgets" but does not recognise "webkitwidgets". Are these names of some files or are they stored in a list somewhere? Or are they supposed to be baked into the qmake executable?
-
@jsulm said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
@mahaju Go to the qtdeclarative folder in Qt source code tree. Then call qmake from your cross compiled Qt, then call "make" and then "make install".
I did all this, but if I try to build my html viewer application, I still get the
Project ERROR: Unknown module(s) in QT: webkitwidgets
when I do qmake NeosQt4.pro
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
I did all this
And did all these steps succeed? Including "make install"? Did you use the correct qmake (the one from your cross compiled Qt)?
-
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
I did all this
And did all these steps succeed? Including "make install"? Did you use the correct qmake (the one from your cross compiled Qt)?
@jsulm said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
@mahaju said in qmake program in my cross compiler for raspberry pi does not recognise webkitwidgets in .pro file:
I did all this
And did all these steps succeed? Including "make install"? Did you use the correct qmake (the one from your cross compiled Qt)?
Yes