PDA

View Full Version : QLCDNumber



highway61ie
4th September 2016, 02:23
Hi ...I'm looking for a way to make a QLCDNumber component of my project to increment each time a switch connected to the GPIO on a PI is activated . I can do it via an onscreen button in my QT project but the question is how do I do it with a "real world physical" button . Basically I want to count each time the switch is activated and display it with QLCDNumber .Any ideas appreciated on how I can replace the onscreen button with a real button if that makes any sense :-) .

d_stranz
5th September 2016, 00:12
You have some method in your Pi code that detects when the GPIO pin goes low (or high, depending on what your switch does), right? If not, you'll need to write one, and there are plenty of examples in the Pi programing world on how to do that. (Like this one) (http://razzpisampler.oreilly.com/ch07.html) When you detect the switch closure, increment a member variable that counts the number of closures, then call QLCDNumber::display().

Basically, you are replacing the slot that gets called on your GUI button click with similar code that detects the Pi switch closure. In both cases, you do the same thing: increment a counter and update the LDC display.

highway61ie
5th September 2016, 03:32
Thank you so much for your help you are a credit to the community ! ..I'm very new to both QT and Pi things ..I'll work on it with your examples and hopefully get there in the end :-)

d_stranz
5th September 2016, 18:22
Well, I have my own Pi, still in the box. One day when I have some free time, I will be learning as well.