|
Post by vovchik on Jun 13, 2022 14:46:47 GMT 1
Dear Joe, I needed to add -fPIC. To get the above code to compile on my Mint. The gui shows, but still nothing via ther terminal. We are getting closer, though, in that there are no compile-time errors or warnings. With kind regards, vovchik
|
|
|
Post by bigbass on Jun 13, 2022 18:00:48 GMT 1
Hello vovchik while I was there looking at the code I added scroll wheel up and down to display in the widget also added a process that gets the qmake version in memory then displays that result to the terminal (if your lucky on mint to see it or not I don't know) a nice feature to run linux commands anyway some improvements we are getting the events in the widgets maybe Peter will find a mint fix for the terminal ? Joe
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QLabel> <QtWidgets/QMainWindow> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QTextBrowser> <QtCore/QProcess> PRAGMA INCLUDE <QtCore/QDebug> <QtGui/QResizeEvent> <QtGui/QWheelEvent> PRAGMA LDFLAGS -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -Wdeprecated-declarations -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC
'---ported by bigbass and greatly simplified https://code.woboq.org/qt5/qtbase/examples/widgets/widgets/mousebuttons/
OPTION PARSE FALSE
'---must include this <QtCore/QDebug> '--- a new macro without formatting or casting or c++ DEF FN PRINTOUT(x) = qDebug() << (x)
DECLARE app TYPE QApplication* DECLARE label TYPE QLabel* DECLARE mainLayout TYPE QGridLayout*
DECLARE button_ TYPE QPushButton* DECLARE textBrowser_ TYPE QTextBrowser* DECLARE win TYPE QWidget*
DECLARE MainWidget TYPE QWidget* DECLARE process TYPE QProcess* DECLARE output TYPE QByteArray '------------------------------------------------ SUB onButtonReleased() '------------------------------------------------
END SUB
'--- no signal or slot it reads in real time '------------------------------------------------ SUB QWidget::resizeEvent(QResizeEvent *event) '------------------------------------------------ qDebug("getting resized" ) END SUB
'------------------------------------------------ SUB QTextBrowser::mouseMoveEvent(QMouseEvent *event) '------------------------------------------------ setMouseTracking(true) qDebug() << event->pos() END SUB
'------------------------------------------------ SUB QTextBrowser::mousePressEvent(QMouseEvent *event) '------------------------------------------------ IF (event->button() == Qt::RightButton) THEN qDebug() << "Right button is pressed" textBrowser_->setText("Right button was pressed") textBrowser_->repaint() ENDIF
IF (event->button() == Qt::LeftButton) THEN qDebug() << "Left button is pressed" textBrowser_->setText("Left button was pressed") textBrowser_->repaint() ENDIF
IF (event->button() == Qt::MiddleButton) THEN qDebug() << "Middle button is pressed" textBrowser_->setText("Middle button was pressed") textBrowser_->repaint() ENDIF END SUB
'------------------------------------------------ SUB QWidget::wheelEvent(QWheelEvent *event) '------------------------------------------------ PRINT "Wheel moving" qDebug() << event->pos()
IF (event->delta() > 0) THEN PRINT "Mouse Wheel Event: up" textBrowser_->setText( "Mouse Wheel Event: up") textBrowser_->repaint() END IF
IF (event->delta() < 0) THEN PRINT "Mouse Wheel Event: down" textBrowser_->setText( "Mouse Wheel Event: down") textBrowser_->repaint() END IF END SUB
app = new QApplication(argc, argv) win = new QWidget
button_ = new QPushButton("Push Me!") textBrowser_ = new QTextBrowser() textBrowser_->setText("") mainLayout = new QGridLayout(win) mainLayout->addWidget(button_,0,0) mainLayout->addWidget(textBrowser_,1,0) win->setWindowTitle("Mouse events Qt5")
'CALLBACKS QObject::connect(button_, &QPushButton::released, onButtonReleased)
win->show() return app->exec()
|
|
|
Post by vovchik on Jun 13, 2022 19:21:56 GMT 1
Dear Joe,
Thanks. I haven't tried yet on Mint, but I get a working binary with a lot of warnings on my Pi4:
Converting 'qt-test9a.bac'... done, 140 lines were processed in 0.018 seconds. Creating lexical analyzer... done. Compiling 'qt-test9a.bac'... g++ -fno-pie -Wno-deprecated -Os -fdata-sections -ffunction-sections -Wl,--gc-sections -Wno-write-strings -Wno-pointer-arith -Wformat=1 -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC -c qt-test9a.bac.c g++ -o qt-test9a qt-test9a.bac.o -s -no-pie -lm -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread -latomic -lm qt-test9a.bac:92:21: warning: ‘int QWheelEvent::x() const’ is deprecated: Use position() [-Wdeprecated-declarations]
INFO: see full error report (y/[n])? y In file included from qt-test9a.bac:144, from qt-test9a.bac.c:2: qt-test9a.bac: In member function ‘virtual void QWidget::wheelEvent(QWheelEvent*)’: qt-test9a.bac:92:21: warning: ‘int QWheelEvent::x() const’ is deprecated: Use position() [-Wdeprecated-declarations] 92 | qDebug() << event->x() << ":" << event->x() | ~~~~~~~~^~ In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QResizeEvent:1, from qt-test9a.bac.generic.h:11, from qt-test9a.bac.h:2, from qt-test9a.bac.c:2: /usr/include/arm-linux-gnueabihf/qt5/QtGui/qevent.h:229:16: note: declared here 229 | inline int x() const { return int(p.x()); } | ^ In file included from qt-test9a.bac:144, from qt-test9a.bac.c:2: qt-test9a.bac:92:43: warning: ‘int QWheelEvent::x() const’ is deprecated: Use position() [-Wdeprecated-declarations] 92 | qDebug() << event->x() << ":" << event->x() | ~~~~~~~~^~ In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QResizeEvent:1, from qt-test9a.bac.generic.h:11, from qt-test9a.bac.h:2, from qt-test9a.bac.c:2: /usr/include/arm-linux-gnueabihf/qt5/QtGui/qevent.h:229:16: note: declared here 229 | inline int x() const { return int(p.x()); } | ^ In file included from qt-test9a.bac:144, from qt-test9a.bac.c:2: qt-test9a.bac:95:18: warning: ‘int QWheelEvent::delta() const’ is deprecated: Use angleDelta() [-Wdeprecated-declarations] 95 | IF (event->delta() > 0) THEN | ~~~~~~~~~~~~^~ In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QResizeEvent:1, from qt-test9a.bac.generic.h:11, from qt-test9a.bac.h:2, from qt-test9a.bac.c:2: /usr/include/arm-linux-gnueabihf/qt5/QtGui/qevent.h:219:16: note: declared here 219 | inline int delta() const { return qt4D; } | ^~~~~ In file included from qt-test9a.bac:144, from qt-test9a.bac.c:2: qt-test9a.bac:102:18: warning: ‘int QWheelEvent::delta() const’ is deprecated: Use angleDelta() [-Wdeprecated-declarations] 102 | IF (event->delta() < 0) THEN | ~~~~~~~~~~~~^~ In file included from /usr/include/arm-linux-gnueabihf/qt5/QtGui/QResizeEvent:1, from qt-test9a.bac.generic.h:11, from qt-test9a.bac.h:2, from qt-test9a.bac.c:2: /usr/include/arm-linux-gnueabihf/qt5/QtGui/qevent.h:219:16: note: declared here 219 | inline int delta() const { return qt4D; } | ^~~~~ qt-test9a.bac: In function ‘int main(int, char**)’: qt-test9a.bac:117:22: warning: ‘void QProcess::start(const QString&, QIODevice::OpenMode)’ is deprecated: Use QProcess::start(const QString &program, const QStringList &arguments,OpenMode mode = ReadWrite) instead [-Wdeprecated-declarations] 117 | process->start("qmake --version") | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/arm-linux-gnueabihf/qt5/QtCore/QProcess:1, from qt-test9a.bac.generic.h:9, from qt-test9a.bac.h:2, from qt-test9a.bac.c:2: /usr/include/arm-linux-gnueabihf/qt5/QtCore/qprocess.h:168:10: note: declared here 168 | void start(const QString &command, OpenMode mode = ReadWrite); | ^~~~~
With kind regards, vovchik
|
|
|
Post by bigbass on Jun 13, 2022 20:11:11 GMT 1
hello vovchik
the mouse wheel code is old but it works on the rpi3
I added the -Wdeprecated-declarations to my code and fixed what I could
in the above code edited
thanks for the feedback and report if you could can you attach the Makefile from the source code mousebuttons that qmake generated (yesterday)
there is something I am missing for mint that will give me more info
Joe
|
|
|
Post by vovchik on Jun 13, 2022 21:31:22 GMT 1
Dear Joe, Here's the Mint makefile.... With kind regards, vovchik Makefile (24.28 KB)
|
|
|
Post by bigbass on Jun 14, 2022 2:03:44 GMT 1
hello vovchik the only thing that caught my eye was MINT Generated by qmake (3.1) (Qt 5.9.5) RPI Generated by qmake (3.1) (Qt 5.11.3) here is my Makefile (so we both have the same info to use) Makefile (24.77 KB) still looking for a clue joe
|
|
|
Post by bigbass on Jun 14, 2022 16:04:41 GMT 1
hello vovchik We have to get terminal out working with Mint and baconized Qt code I will take a big step back and have an empty window just for the GUI code and a terminal out using debug this will tell us if it is possible or not then build up from here hope all is well with you today and you had some coffee first Joe
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> <QtCore/QTime> <QtCore/QDate> PRAGMA INCLUDE <iostream> PRAGMA LDFLAGS -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE cd TYPE QDate DECLARE ct TYPE QTime '---must include this <QtCore/QDebug> '--- a new macro without formatting or casting or c++ DEF FN PRINTOUT(x) = qDebug() << (x) app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget()
cd = QDate::currentDate() ct = QTime::currentTime()
PRINT "Current date is: " PRINTOUT(cd.toString()) PRINT "Current time is: " PRINTOUT( ct.toString())
w->resize(150, 60) w->setWindowTitle("Date Time") w->show() return app->exec()
|
|
|
Post by bigbass on Jun 14, 2022 17:18:22 GMT 1
Hello vovchik if that worked then place it in the widget
PRAGMA INCLUDE <QtCore/QTime> <QtCore/QDate> PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QTextBrowser> <QtCore/QProcess> PRAGMA INCLUDE <QtCore/QDebug> PRAGMA INCLUDE <iostream> PRAGMA LDFLAGS -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE mainLayout TYPE QGridLayout* DECLARE button_ TYPE QPushButton* DECLARE textBrowser_ TYPE QTextBrowser* DECLARE MainWidget TYPE QWidget* DECLARE cd TYPE QDate DECLARE ct TYPE QTime '---must include this <QtCore/QDebug> '--- a new macro without formatting or casting or c++ DEF FN PRINTOUT(x) = qDebug() << (x) app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() textBrowser_ = new QTextBrowser() textBrowser_->setText("") mainLayout = new QGridLayout(w) mainLayout->addWidget(textBrowser_,0,0) w->setWindowTitle("Date Time Qt5") cd = QDate::currentDate() ct = QTime::currentTime() PRINT "Current date is: " PRINTOUT(cd.toString()) PRINT "Current time is: " PRINTOUT( ct.toString()) '--- get those QDate and QTime values into the widget as a string textBrowser_->append("Current date is: ") textBrowser_->append(cd.toString()) textBrowser_->append("Current time is: ") textBrowser_->append(ct.toString()) textBrowser_->repaint()
w->resize(300, 150 ) w->setWindowTitle("Date Time Qt") w->show() return app->exec()
|
|
|
Post by vovchik on Jun 14, 2022 18:22:47 GMT 1
Dear Joe, Thanks. Here is a screenshot from Mint! With kind regareds, vovchik
|
|
|
Post by bigbass on Jun 15, 2022 14:46:36 GMT 1
Hello vovchik thanks for the feedback and the good report about Mint! Hello everyone how about the easiest web viewer for Qt running on bacon ? no way ! Qt is bloated and it uses c++ and forget about porting code to bacon ... I got past those thoughts and just gave it a try the final binary size after compiling is 36kb I will add more features but we have to start with the minimum needed for the first demo notes: right click to get options to go forward and back you will need this sudo apt-get install libqt5webkit5-dev
Joe PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <QtCore/QDebug> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread -latomic PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC OPTION PARSE FALSE
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView() view->load(QUrl("http://google.com")) view->resize(600, 600 ) view->setWindowTitle("Bacon Qt Browser demo 1") view->show() return app->exec()
|
|
|
Post by vovchik on Jun 15, 2022 21:45:41 GMT 1
Dear Joe, Thanks. The code is TINY!!!!! I get the google page loading and see the input box, but on both PI and Mint I get a strange dark grey overlay and can't seem go get into the input box. The code compiles fine on both platforms. With kind regards, vovchik
|
|
|
Post by bigbass on Jun 16, 2022 0:16:12 GMT 1
Hello vovchik
it is almost there
how about commenting out two lines and see if that helps
'view->resize(600, 600 ) 'view->setWindowTitle("Bacon Qt Browser demo 1")
and let the defaults do their thing added
PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> <QtWebKit/QtWebKit> <QtWebKitWidgets/QtWebKitWidgets>
Joe
|
|
|
Post by Pjot on Jun 16, 2022 16:35:19 GMT 1
Hi Joe, On my system I have the same greyed out browser as vovchik. Commenting those two lines does not help. But I think it has to do with google.com website itself. Because if I load the BaCon website, all works Best regards Peter PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/x86_64-linux-gnu/qt5 -fPIC OPTION PARSE FALSE
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView*
app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView()
view->load(QUrl("https://www.basic-converter.org")) view->resize(600, 600 ) view->setWindowTitle("Bacon Qt Browser demo 1") view->show() return app->exec()
Attachments:
|
|
|
Post by vovchik on Jun 16, 2022 19:34:43 GMT 1
Thanks Peter and Joe. I added a very elementary command-line feature, which means we can easily try out this handy nano browser on various sites without recompiling.
Here is the code:
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lpthread PRAGMA COMPILER g++ PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/x86_64-linux-gnu/qt5 -fPIC OPTION PARSE FALSE
DECLARE app TYPE QApplication* DECLARE w TYPE QWidget* DECLARE view TYPE QWebView* DECLARE URL$ TYPE STRING
' Get URL from the command line URL$ = CHOP$(MID$(ARGUMENT$, INSTR(ARGUMENT$, " "))) 'e.g. .qtbrowse-pjot-cli "https://www.basic-converter.org" PRINT "URL: ", URL$
app = new QApplication(argc, argv) '--- Create a widget instead of a window w = new QWidget() view = new QWebView()
view->load(QUrl(URL$)) view->resize(600, 600 ) view->setWindowTitle(URL$) view->show() return app->exec()
With kind regards, vovchik
|
|
|
Post by bigbass on Jun 17, 2022 4:44:33 GMT 1
Hello Peter thanks for testing and the feedback glad to see it works on your system!
Hello vovchik
I like that you are making things more baconized that's the idea we just do the minimum we can to make the Qt GUI work then let bacon glue the rest together
the command line run is nice
I called it v.bac then ./v "https://www.basic-converter.org"
this is very useful when we want to read some docs but don't want to open chrome for example you are running Qt Creator and you don't want to bog down the memory by opening chrome
thanks Joe
|
|