All of these demos will be preset for the raspberry 'RPI3
but can easily be changed for x86_64 changing and uncommenting one line of code
I also tried this on Manjaro archlinux RPI3
'RPI3
PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC
but lets say you want to test on an x86_64
well just comment out the the PRAGMA line for the RPI3
and uncomment the x86_64 PRAGMA line
'x86_64
PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -Wno-deprecated-declarations -fPIC -I/usr/include/x86_64-linux-gnu/qt5
I like archlinux Manjaro too very cutting edge software versions!
'Manjaro archlinux RPI
PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/qt5 -fPIC
dowload the source code
'--you will need this
'---sudo apt-get install libqt5webkit5-dev
'Manjaro
'packan -Syu qt5webkit
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow>
PRAGMA INCLUDE <QtCore/QDebug> <QtWidgets/QGridLayout> <QtWidgets/QPushButton> <QtWidgets/QLineEdit> <QtWidgets/QFileDialog>
PRAGMA INCLUDE <iostream> <QtWebKitWidgets/QWebView> <QtCore/QDebug> <QtCore/QDir> <QtCore/QDir>
PRAGMA LDFLAGS -lQt5WebKitWidgets -lQt5Widgets -lQt5WebKit -lQt5Gui -lQt5Network -lQt5Core -lpthread -latomic
PRAGMA COMPILER g++
'RPI3
PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/arm-linux-gnueabihf/qt5 -fPIC
'x86_64
'PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -Wno-deprecated-declarations -fPIC -I/usr/include/x86_64-linux-gnu/qt5
'Manjaro archlinux RPI
'PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/qt5 -fPIC
'--you will need this
'---sudo apt-get install libqt5webkit5-dev
'Manjaro
'packan -Syu qt5webkit
OPTION PARSE FALSE
DEF FN PRINTOUT(x) = qDebug() << (x)
'---------------------------------------
SUB urlEdit_cb()
'---------------------------------------
PRINT "RETURN PRESSED"
LOCAL bstr TYPE QString
bstr = urlEdit->text()
PRINTOUT( bstr)
view->load(("http://"+urlEdit->text()))
END SUB
'---------------------------------------
SUB backButton_cb()
'---------------------------------------
view->back()
END SUB
'---------------------------------------
SUB forwardButton_cb()
'---------------------------------------
view->forward()
END SUB
'---------------------------------------
SUB reloadButton_cb()
'---------------------------------------
view->reload()
END SUB
'---------------------------------------
SUB goButton_cb()
'---------------------------------------
view->load(("http://"+urlEdit->text()))
END SUB
'---------------------------------------
SUB openFile_cb()
'---------------------------------------
LOCAL filename TYPE QString
filename = QFileDialog::getOpenFileName(0,"Open a File","","Local File (*.*)")
view->load("file://"+filename)
view->show()
PRINTOUT(filename)
END SUB
DECLARE app TYPE QApplication*
DECLARE w TYPE QWidget*
DECLARE view TYPE QWebView*
DECLARE Layout TYPE QHBoxLayout*
DECLARE backButton TYPE QPushButton*
DECLARE forwardButton TYPE QPushButton*
DECLARE reloadButton TYPE QPushButton*
DECLARE goButton TYPE QPushButton*
DECLARE urlEdit TYPE QLineEdit*
DECLARE HLayout TYPE QWidget*
DECLARE openButton TYPE QPushButton*
app = new QApplication(argc, argv)
'--- Create a widget instead of a window
w = new QWidget()
view = new QWebView(w)
view->setObjectName(QStringLiteral("view"))
view->setGeometry(QRect(10, 90, 800, 590))
view->setUrl(QUrl(QStringLiteral("bing.com")))
urlEdit = new QLineEdit(w)
urlEdit->setObjectName(QStringLiteral("urlEdit"))
urlEdit->setGeometry(QRect(10, 10, 500, 30))
'---tricky to get working the first time
'---horizontalLayoutWidget I shortened to HLayout
'---this is needed to keep all the buttons in order as you can see it is
'---another QWidget inside the main widget w
'---I did this so I could use absolute postioning of the widgets
HLayout = new QWidget(w)
'--- x y length width of the container
HLayout->setGeometry(QRect(10, 30, 501, 61))
Layout = new QHBoxLayout(HLayout)
Layout->setSpacing(6)
Layout->setContentsMargins(11, 11, 11, 11)
Layout->setContentsMargins(0, 0, 0, 0)
'--- more code needed when using a layout manager
backButton = new QPushButton("Back",HLayout)
Layout->addWidget(backButton)
forwardButton = new QPushButton("Forward",HLayout)
Layout->addWidget(forwardButton)
reloadButton = new QPushButton("Reload",HLayout)
Layout->addWidget(reloadButton)
goButton = new QPushButton("Go",HLayout)
Layout->addWidget(goButton)
'---added an option to open a local file or webpage
openButton = new QPushButton("Open...",HLayout)
Layout->addWidget(openButton)
'---CALLBACKS for SUBS
QObject::connect(backButton, &QPushButton::released, backButton_cb)
QObject::connect(forwardButton, &QPushButton::released,forwardButton_cb)
QObject::connect(reloadButton, &QPushButton::released, reloadButton_cb)
QObject::connect(goButton, &QPushButton::released, goButton_cb)
QObject::connect(urlEdit, &QLineEdit::returnPressed, urlEdit_cb)
QObject::connect(openButton, &QPushButton::released, openFile_cb)
view->load(QUrl("http://bing.com"))
w->setWindowTitle("Bacon Qt Browser layout demo2")
w->resize(800, 500)
w->show()
return app->exec()