Qt5: How to create interrupt driven gpio button based qt app - c++

My problem is......... I am trying to develop an application.In this application there are certain pages and which is displaying on the LCD on my board.and my board has a gpio button by default the value of this button is high when i press this button value of this button become low after releasing again high.i want to make my app interrupt based when i pressed hold button for 3 second display should be rotate and if i just press and release button page should change.In my app i have interface my gpio button.
QString btnInput = "/sys/class/gpio/gpioN/value";
In my apps I can read the value from value file when my app start after that if i press button nothing will happen.what should i do.
how can i generate interrupt after pressing button.
please help me i am new in qt I start qt just before 2 week.

I can't tell for a Qt5 application actually (I don't have experience in the Qt field), but you may use a inotify file watcher with /sys/class/gpio/gpioN/value in user space.
That way your program will receive notifications (interrupts) whenever the value changes.
I'm almost sure there's also some (portable) Qt intrinsic mechanism, that resembles the same.
Update (after a little research):
Specifically for Qt I found this answer where the QFileSystemWatcher is mentioned for doing that portably.

Related

How can I save Checkbox selection in qt c++?

I am trying to develop an application with QT C++. I added a checkBox. How can I make my checkBox be in the last selection when I close my app and open it again. For example, if the checkbox was selected before the application was closed, I want it to be selected when the application runs again. If it wasn't selected before closing, it should come back unselected when it runs again. How can I do that?
Read the value of the checkbox when your app shuts down. Save the value somewhere, like; QSettings, a custom file, windows registry, etc. When your application starts, read the stored value and set the checkbox state to match.

qt - Pushing multiple QPushButtons at the same time

I couldn't find an answer to this so here goes nothing:
I'm developing a GUI for an embedded Linux and it needs to be able to push 2 buttons and do different functions when one of the 2 is already pushed (like a shiftbutton on your keyboard). I tried using button->setAutoRepeat(true);
It does what it says but it doesn't allow other buttons to be pressed at the same time. The embedded Linux system has a 10-finger touchscreen so it should allow multiple buttons at the same time.
TL;DR: I can't find a way to press another button while a button is already pressed.
Solution 1:
Use QAbstractButton::isDown() to check if the shift like button is down when processing event in the action button.
Solution 2:
QAbstractButton hsd setChecked/isChecked functions which can be useful.
Solution 3:
Subclass the QPushButton and reimplement keyPressEvent or you can install event filter for your button and process QMouseEvent. This solution will give you more flexibility in your code.
Choose one of it depending on usage and requirement.

How to know if computer is in gaming mode

Background
I'm implementing a simple WIN32 application consist of a window.
The user may show/hide the window using a special hotkey. I register the hotkey using RegisterHotKey and respond to WM_HOTKEY
Problem
if user plays a game and accidentally (or not accidentally) press the hotkey combination, then my window pops up and as a result the game is minimized.
Question
Is there a (native) way to know that the user is in gaming mode, or any other special mode, that I could disable the hotkey response
Note
I would also like if windows would make this a feature while I play games. For example don't respond to WinKey+D while I'm in gaming mode.
You can use the SHQueryUserNotificationState function to determine whether the user is playing a full screen D3D game. It will report QUNS_RUNNING_D3D_FULL_SCREEN.

Paste From QT Window to Another Application Input Widget

I am very new to C++ programming and the bulk of my program will be using the QT libraries. However, there is one part where I believe I will need to use Win32.
The scenario I want to code for is as follows:
I will have a QT application running. I want to be able to take some text which has been typed into a TextBox on the QT Window and paste that text into a TextBox in another application e.g. the address bar of Chrome, the address bar of Windows Explorer.
I want to be able to do that as a response to a button click on the QT Window. So, it would all happen in 3 steps. For example:
User types text into QT Window;
User places cursor in address bar of Chrome (Browser);
User clicks button on Window which pastes text into address bar of Chrome.
A nudge in the right direction would be most appreciated.
Edit - Additional Info
The application I’m building is a self-set assignment. I want to build a clipboard manager, similar to this old Delphi application http://www.joejoesoft.com/vcms/97/ . It will run in the system tray, in a minimised state.
The user, will put their focus into a text input in some application
which is running on their Windows machine e.g. Notepad.
Then, they will hit a hot key combination which will open a form (my QT Window.
The application will have been collecting clips as the user presses Ctrl-C (or by right-clicking) and those will be listed in that QT Form (just like the app in the link above).
The user then clicks on the particular item that they want paste and it will be pasted into the original input that they had put the cursor into.
Further Edit - further info
I'll break step 4 into a couple of sub-steps as it is causing confusion:
The user then clicks on the particular item that they want paste
Focus changes from QT Window back to the window of the other Win32 application which originally had focus
Content is pasted into the input control which now has the focus
I pretty much know how I can gather up items when the user copies things. But I have no idea how I will paste from my application to the target application.
Cheers

Windows Phone 8 manual application exit c++

I am writing a C++ DirectX application without XAML for Windows Phone 8. I have met on difficulty. In the certifications requirements it is mentioned that:
"Verify that either the app closes without error, or allows the user
to confirm closing the app with a menu or dialog."
When on the main screen user presses back button I show the yes-no dialog. When user presses Yes how should I make the app exit?
In this topic there are some solutions but they seem to work only with XAML.
http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/fdedf8f6-e691-4df6-92c7-ed3dc97bddc0/
How should I close the app?
Looking at that MSDN forum link it seems that the back key press logic in C++/DirectX works in the same way as C#/XAML.
I.e. If you set the handled flag command->Handled = true; in the Back key press handler the application framework will not close the app.
If you don't set the flag then the application framework will close the app.