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 -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
note demo5 has the callbacks connected and working more advanced
PRAGMA INCLUDE <QtWidgets/QApplication> <QtWidgets/QMainWindow> <QtWidgets/QComboBox> <QtWidgets/QHBoxLayout> <QtWidgets/QLabel>
PRAGMA INCLUDE <QtWidgets/QPushButton> <QtWidgets/QStatusBar> <QtWidgets/QFrame> <QtWidgets/QVBoxLayout>
PRAGMA INCLUDE <QtWidgets/QListWidget> <QtCore/QDebug>
PRAGMA INCLUDE <iostream>
PRAGMA LDFLAGS -lQt5Widgets -lQt5Gui -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 -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
OPTION PARSE FALSE
'x86
'PRAGMA OPTIONS -Wno-write-strings -Wno-pointer-arith -I/usr/include/x86_64-linux-gnu/qt5 -fPIC
'---must include this <QtCore/QDebug>
'--- a new macro without formatting or casting or c++
DEF FN PRINTOUT(x) = qDebug() << (x)
'--------------------------------------
SUB addPressed()
'--------------------------------------
Statusbar->showMessage( "add", 4000)
'---note the 4000 is 4 seconds to view the message
END SUB
'--------------------------------------
SUB renamePressed()
'--------------------------------------
Statusbar->showMessage("rename ", 4000)
END SUB
'--------------------------------------
SUB removePressed()
'--------------------------------------
Statusbar->showMessage("remove", 4000)
END SUB
'--------------------------------------
SUB removeallPressed()
'--------------------------------------
Statusbar->showMessage("remove all ", 4000)
END SUB
'--------------------------------------
SUB clickedsub()
'--------------------------------------
'--- I figured out how to get the selected from a click
Statusbar->showMessage(lw->currentItem()->text(), 4000)
'--- how to get the terminal out strings of the selected text
PRINTOUT(lw->currentItem()->text())
END SUB
DECLARE app TYPE QApplication*
DECLARE hbox TYPE QHBoxLayout*
DECLARE vbox TYPE QVBoxLayout*
DECLARE add TYPE QPushButton*
DECLARE renamed TYPE QPushButton*
DECLARE removeme TYPE QPushButton*
DECLARE removeall TYPE QPushButton*
DECLARE lw TYPE QListWidget*
DECLARE Statusbar TYPE QStatusBar*
DECLARE w TYPE QWidget*
app = new QApplication(argc, argv)
'--- Create a widget instead of a window
w = new QWidget()
hbox = new QHBoxLayout()
vbox = new QVBoxLayout()
lw = new QListWidget()
lw->addItem("apples")
lw->addItem("oranges")
lw->addItem("mangos")
lw->addItem("bananas")
lw->addItem("lemons")
add = new QPushButton("Add")
renamed = new QPushButton("Rename")
removeme = new QPushButton("Remove")
removeall = new QPushButton("Remove All")
vbox->setSpacing(3)
vbox->addStretch(1)
vbox->addWidget(add)
vbox->addWidget(renamed)
vbox->addWidget(removeme)
vbox->addWidget(removeall)
vbox->addStretch(1)
hbox->addWidget(lw)
hbox->addSpacing(15)
hbox->addLayout(vbox)
'--- Set the hbox as the layout of the widget
'--- this fixes having a window and a widget that are not joined
Statusbar = new QStatusBar()
'---add the statusbar widget
hbox->addWidget(Statusbar, 3, Qt::AlignBottom)
w->setLayout(hbox )
QObject::connect(add, &QPushButton::clicked, addPressed)
QObject::connect(renamed, &QPushButton::clicked, renamePressed)
QObject::connect(removeme, &QPushButton::clicked, removePressed)
QObject::connect(removeall, &QPushButton::clicked, removeallPressed)
'--- added a custom callback to get the listwidget
'QObject::connect(lw, &QListWidget::itemDoubleClicked, doubleclickedsub)
QObject::connect(lw, &QListWidget::itemClicked, clickedsub)
w->resize(500, 200)
w->setWindowTitle("Listwidget demo")
w->show()
return app->exec()