salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Sun Sep 29, 2019 5:39 pm

Hi. Try rigth clicking over the "widget" (button or other...).
In the flying menu choose "Go to Slot..." and select the event (Signal in Qt jaergon) you want to catch.
Click OK and a new "Slot" (The catching function...) will be created for you and the editor will open in the right place.

Ciao

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Sun Sep 29, 2019 8:51 pm

aaahhh.. that works for my buttons, thank you!


Now I added in the tool bar a tool "File" providing an extra drop-down option "Quit" (submenu)

Code: Select all

____________________________|
File                        |
 |->Quit |                  |
                            |
                            |
                            |
                            |
            [Quit]          |
 ___________________________|
which shall do the same as pressing the Quit-Button, but whilst for the Quit button there is a slot, there ain't one for the tool bar "Quit" option...
what am I missing, and how can I handle the dropdown-submenu option instead?

(ftm it's of course redundant, but later on I want to create a 2nd tool ("Inputs") with dropdown options to switch
GPIO24: input_pulldown <-> input_pullup)


dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Mon Sep 30, 2019 9:41 am

thank you for your link, but unfortunately I still don't know how to proceed - I just needed a slot for a signal (click) of a dropdown-menu option :(

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Tue Oct 01, 2019 10:34 am

Hi.
I think that is very similar to the way you did for the buttons...
My English is so poor that I'm not sure to be able to explain clearly, anyway...I'll try.

In the Form editor you can add a menu item by writing in the space were you read "Type Here" and the pressing return to confirm.
A submenu can be added by clicking on the small icon that you will see when you click on the previously added item.
In the lower window, the new "action" will appear and if you right-click on it a flying menu will appear: choose "Go to slot..." and you will have a new slot created for you.

Gabriele

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Tue Oct 01, 2019 2:26 pm

which is your language? do you speak German?
Unfortunately my English is also very poor.
I was able to add the "File" toolbar thing and also to add the drop-down submenu "Quit" (like shown in my text window simulation above), but I cannot get either functionality for them, it's just there but don't do nothing and it has no slot and no event signal to be assigned to it.

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Wed Oct 02, 2019 4:39 am

Once you have inserted the Menu items like this:
A.jpg
A.jpg (142.65 KiB) Viewed 1097 times
You will have a new action added in the window below. Then if you right click on the line you can add your slot like this:
B.jpg
B.jpg (153.19 KiB) Viewed 1097 times

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Wed Oct 02, 2019 8:51 am

IIUC, my actionQuit is for my Quit Button,
but I don't understand how to create a slot and a signal for the extra drop down option


dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Wed Oct 02, 2019 10:00 am

thank you, but I still do not see how to create the drop down menu slot by qt designer in the grafic form window like for the buttons -
OTOH, if I add the function manually in mainwindow.cpp

Code: Select all

void
MainWindow::on_actionQuit_triggered() {
    ui->statusBar->showMessage("File Quit menu activated", 2000);
//    exit(EXIT_SUCCESS);
}
then the compiler gives an error
no void MainWindow::on_actionQuit_triggered() member function declared in class 'MainWindow'
IMO, the IDE actually should create the function wrapper automatically with all included or required dependencies... :?:

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 7:27 am

how did you manage to create the widget class="QStatusBar" and the signal MainWindow::on_actionQuit_triggered()?

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 8:37 am

Hi
The QMainWindow (that is the subclass of your MainWindow) already has a QStatusBar widget accessible as ui->statusBar (unless you change its name) or you have deleted it.
I suggest you to take your time in reading and trying to understand this:
https://doc.qt.io/qt-5/qmainwindow.html#details.
As I already told you, by right clicking on the line "actionQuit" that appears on the "Action Editor" window you can access the "Go to slot..." menu that allows you to add the Slots to handle the various Signals that the menu item can emit.
If you select "triggered()" you will have the "on_actionQuit_triggered()" slot added to your "MainWindow" class.

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:10 am

yes thank you, you told me, but I don't understand the single steps - I do not see either option in any right-mouse-click-menu on either spot in any window when trying to open a slot for the drop-down menu option "quit"
when right clicking directly on the drop-down-quit-option I don't get a "go to slot", other than for the buttons.
And as the status bar shows a place to enter a tool for a status-drop-down menu ("File") and a drop-down option ("Quit") I actually doubt that I might have deleted it.

OTOH, if such a subclass or whatever already exists, why do I get the compiler error when adding your code manually?

really weird, tbh... :?

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:22 am

How do you get into the form editor ?

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:26 am

After having opened the project file (*.pro) I click on the left side of the IDE beyond "open file" or drop-down-menu File-open on "mainwindow.ui"
then the designer window for my form appears.
then it looks similar like here
https://www.raspberrypi.org/forums/down ... p?id=32383
Last edited by dsyleixa123 on Thu Oct 03, 2019 9:32 am, edited 1 time in total.


dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:39 am

yes, it looks similar
besides 2 additonal entries:

Code: Select all

Name
   actionGPIO23
   actionQuit
   actionGPIO24
(I actually thought that actionQuit is for the Quit-Button...?)
anyway, it seems to be there...


right mouse click on actionQuit

Code: Select all

   Neu...
   Ändern...
   Slot anzeigen...
   Verwendet in   >
   Ausschneiden
   Kopieren
   Einfügen
   Alles auswählen
   Löschen
   Icon Ansicht
 O Detaillierte Ansicht

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:57 am

then... try clicking on "Slot anzeigen.."

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 9:58 am

ok, then I chose
"Slot anzeigen..."
a new window appears, suggesting "triggered()" and many more
I chose "triggered()"
it switches to the text editor
then the IDE had added a new function wrapper

Code: Select all

void
MainWindow::on_actionQuit_triggered() {
 
}
I added your code inside,
saved
ctrl-r
the message is shown!

then
outcommented the showmessage line
uncommented exit line
saved
ctrl-r

now it works! 8-) 8-) 8-)

now I will proceed to the wiringPi functions in a toolbar "Edit" submenu for GPIO24 pullup vs. pulldown (if supported)

thank you very much!! 8-) 8-) 8-)

(out of interest: why was there no entry for the quit button, but just for the 2 GPIO buttons and the tool bar option?)
Last edited by dsyleixa123 on Thu Oct 03, 2019 10:03 am, edited 2 times in total.

salvato
Posts: 75
Joined: Tue Jan 15, 2013 9:21 pm

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 10:02 am

I suggest you to try experiment without be worried. Your Pi is no in danger !


dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 10:30 am

update, I think I got it basically, (I hope):
https://github.com/dsyleixa/RaspberryPi ... Pi_toolbar (edit: now functional!)

share and enjoy! 8-)
Last edited by dsyleixa123 on Thu Oct 03, 2019 4:51 pm, edited 1 time in total.


dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Thu Oct 03, 2019 4:02 pm

update:
the function has been implemented successfully, it works like a charm! 8)

Code: Select all

/*
 * GPIO setup (BCM numbering):
 * 23: Output (green LED + resistor) // switchable by widget buttons)
 * 24: Input  (default: GPIO24->switch->GND)
 * 25: Output (red LED + resistor)  // LED is lit while program runs
 *
 * Input 24 can be switched from INPUT_PULLUP (default) to INPUT_PULLDOWN
 * (beneath toolbar option Edit)
 * when  INPUT_PULLDOWN  is activated, the switch has to be re-wired
 * (GPIO24->switch->+3v3)
 *
*/

dsyleixa123
Posts: 462
Joined: Mon Jun 11, 2018 11:22 am

Re: qtcreator (qt5, qtdesigner): how to access GPIOs (r/w pins, i2c devices, UART,...)?

Fri Oct 04, 2019 8:28 am

just a question for understanding:
you are using statements like
pin23=HIGH;
pin23=LOW;

but where is declared what kind of variable pin23 is?

Return to “C/C++”