A word about Qt internals: mapping input to interface



  • Hi,

    my problem is the following and I'm not interested in any piece code, just the theory and the data structures behind this : I have a piece of software that when an input is triggered for a device ( a mouse click or a touch ) it gives me the coordinates where the event occurred, and I have to map this event to my GUI.

    the question is what is the data structure used by Qt, or other GUI frameworks in general, to perform the mapping between the input ( for example the input given by Xlib under X11 ) and what I see on the screen ?

    I would like to read something about data structures that can solve this problem and what is the one choosed by the Qt team, but I suspect that is something like a graph or a tree.

    Thanks.


  • Lifetime Qt Champion

    Hi,

    There's not one answer, it all depends on the underlying platforms. Generally you will have your framework using a defined system and abstraction for inputs and then backends that translate the various platforms inputs in your framework's system.

    Hope it helps



  • [quote author="SGaist" date="1387665204"]Hi,

    There's not one answer, it all depends on the underlying platforms. Generally you will have your framework using a defined system and abstraction for inputs and then backends that translate the various platforms inputs in your framework's system.

    Hope it helps[/quote]

    Qt uses multiple data structures depending on the target platform ? Are you sure you are not referring to the API/design of the underlying system specific implementation ?

    My focus is just the data structure for this, nothing more, nothing less.


  • Moderators

    Hi,

    I'm not 100% what you mean by "data structure", but all GUI input events in Qt are represented by objects derived from the QEvent class (e.g. QMouseEvent, QTouchEvent).

    What SGaist means is: The underlying windowing system, which generates these events, are different for each platform. Thus, the internal Qt code that interfaces with the windowing system and create these QEvent objects are platform-dependent.

    You could start by studying the documentation and source code for the various subclasses of QEvent:



  • [quote author="JKSH" date="1387687353"]Hi,

    I'm not 100% what you mean by "data structure", but all GUI input events in Qt are represented by objects derived from the QEvent class (e.g. QMouseEvent, QTouchEvent).

    What SGaist means is: The underlying windowing system, which generates these events, are different for each platform. Thus, the internal Qt code that interfaces with the windowing system and create these QEvent objects are platform-dependent.

    You could start by studying the documentation and source code for the various subclasses of QEvent:

    I'm talking about Qt internals, something that is probably not exposed in any public class.

    Usually a server like X under Linux gives you a pair of coordinates when an even happens, when you click or move your mouse the server fires an event.

    Now the problem is how to map that event with your layout/widget/window ? How to handle the rescaling of windows and the rescaling of the layout ? I don't know how this works under Qt but you probably need a data structure of some kind just to do the mapping between your input / pair of coordinates and your graphical layout .

    EDIT: to clarify further, a similar task is usually handled by libXt under X11, but as far as I know libXt handles input and does this kind of mapping for a widget, not for a window, also I'm interested in the nitty gritty details of this.


  • Lifetime Qt Champion

    Then have a look at the various platform plugins



  • I think that I'll wait for an answer from some Qt developer from the "core" team, if they still are here on this forum.


  • Moderators

    The devs from the core team do not visit this forum. They are on the Interest mailing list or IRC (see http://qt-project.org/wiki/OnlineCommunities ). Note that they are currently on holiday; their offices are closed for Christmas and New Year.

    The best way to get into the nitty gritty details is to have a look at the source code. You want the "Qt Platform Abstraction":http://qt-project.org/doc/qt-5/qpa.html (QPA) API. As one "Digia writer said":https://blog.qt.digia.com/blog/2013/07/23/anatomy-of-a-qt-5-for-android-application/,
    [quote]Qt abstracts away the windowing system in an API called "QPA", so that platform-dependent code can be isolated to a plugin. This plugin will handle everything from putting graphics on the screen to propagating events from the windowing system and into your Qt event loop.[/quote]

    [quote author="kriu" date="1387693075"]as far as I know libXt handles input and does this kind of mapping for a widget, not for a window[/quote]Both QWindow and QWidget are built on top of QPA.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.