Menu

demo1

big-bass
Attachments
demo1.bac (1505 bytes)
demo1.png (2539 bytes)

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

demo1 QT5

dowload the source code

demo1.bac

PRAGMA INCLUDE <QtWidgets/QApplication>  <QtWidgets/QLabel>  <QtWidgets/QMainWindow> <QtWidgets/QPushButton>
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


'--- our signal /slot  from Qt  placed in a  bacon SUB 
SUB handleButton() 
    PRINT "Qt callback hack working with events"
    '--- change the text
    m_button->setText("Example")
   '--- resize button
    m_button->resize(100,100)
ENDSUB




    DECLARE app TYPE QApplication*
    DECLARE mainWindow TYPE QMainWindow*
    DECLARE m_button  TYPE QPushButton*
    app = new QApplication(argc, argv)




    '--- mainwindow.cpp used in Qt modified and redirected  the signal/slot to a bacon SUB
    '--- Create the button
    m_button = new QPushButton("Qt Button")
    '--- set size and location of the button
    m_button->setGeometry(QRect(QPoint(100, 100), QSize(200, 50)))

    '--- Connect button signal to appropriate slot hacked for a BaCon SUB
    '--- had to add the QObject::   to the connect to get this to work in bacon
    QObject::connect(m_button, &QPushButton::released,  handleButton)


    m_button->show()
    return app->exec()

Discussion

  • big-bass

    big-bass - 2022-09-07

    Qt5 is not an easy thing to use.
    but it is very powerful and many professional apps have been made with it https://wiki.manjaro.org/index.php?title=List_of_Qt_Applications

    That being said mixing it with bacon can be a mind bending experience
    since Qt uses their own way of connecting events with SIGNALS and SLOTS (they don't use the standard callbacks)
    and it uses C++

    I was able to shorten the code using only one file and no classes and have bacon type callbacks!

    I believe the best way to learn is by having some working demo code and get to the point quickly

     
  • big-bass

    big-bass - 2022-09-07

    I am going to explain in my own words the porting of QT to bacon
    this is the same example in QT
    https://wiki.qt.io/How_to_Use_QPushButton

    will do this in a full page

     

    Last edit: big-bass 2022-09-07

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.