If you are trying to randomly query the state of the keyboard modifiers and mouse buttons, then you can query them on the QApplication class as static methods :
http://qt-project.org/doc/qt-4.8/qapplication.html#keyboardModifiers
http://qt-project.org/doc/qt-4.8/qapplication.html#mouseButtons
But if this actually how you are going to use them, by starting a timer that checks repeatedly? The other way is to watch for the actual events to occur, and react.