Results 1 to 3 of 3

Thread: Extending QMouseEvent a SECOND time? (within Qt itself)

  1. #1
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Extending QMouseEvent a SECOND time? (within Qt itself)

    I'll ask here in the forum, because I keep "crazy" hours in comparison to EU. Thanks in advance for any-all comments and suggestions. This is in preparation for attempting a change in Qt itself, not in "user code".

    When I'm done providing background information, the questions are very simple- but I just don't know the answers.

    Within /src/kernel/gui/kernel/qevent, QMouseEvent is given multiple declarations, and it's re-cast dynamically. Here's the relevant snippet of the current (4.7.1) declarations in qevent.h, lines 82-105:
    Qt Code:
    1. public:
    2. QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
    3. Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
    4. QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
    5. Qt::MouseButton button, Qt::MouseButtons buttons,
    6. Qt::KeyboardModifiers modifiers);
    7.  
    8. inline const QPoint &pos() const { return p; }
    9. inline const QPoint &globalPos() const { return g; }
    10. inline int x() const { return p.x(); }
    11. inline int y() const { return p.y(); }
    12. inline int globalX() const { return g.x(); }
    13. inline int globalY() const { return g.y(); }
    14. inline Qt::MouseButton button() const { return b; }
    15. inline Qt::MouseButtons buttons() const { return mouseState; }
    16.  
    17. static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
    18. const QPoint &globalPos, Qt::MouseButton button,
    19. Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
    20. inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
    21. QPointF posF() const;
    22.  
    23. #ifdef QT3_SUPPORT
    24. // followed by irrelevant QT3 constructors, etc.
    To copy to clipboard, switch view to plain text mode 

    The "Extended Info" was introduced with 4.4 (a "minor" Release), and it attempts to provide the new "Global Positioning" as a set of automatically-paired floating point values (rather than the int values in the previous constructor.) This is done dynamically via the "reinterpret_cast" test, SOMEHOW. The same thing is done with QKeyEvent at line 235 of the header file, adding declaration of three quint32 "native" data fields.
    - - - -
    Ultimately, my objective is the partial support of "gaming mice" buttons in the X11 platform. I can't do this, WITH backward compatibility, by simply using the current "button-causing-the-event" field as the unsigned integer which X11 actually provides to us. (Binary Qt programs created within a "Qt 4.8" environment would have different button numbers for the same bits in "Qt.MouseButton" enum provided by library code in boxes running 4.0 thru 4.7). Maybe I need to create and manipulate an "extended info" data field, of type quint32, to hold a compatible bit-mask enum wide enough to add buttons 10-32.

    And if so: Can I add a SECOND *createExtendedMouseEventVersion2 signature, adding this field? And maybe also another boolean test function result, "hasExtendedInfoV2() ? If so, what kind of test can I do for a dynamic test to declare and utilize the field?

    Please advise me of your ideas on "smart" ways to create this enhancement, while preserving BC with all previous QT4 Releases. And again, my thanks for your patience and expertise in giving me "a clue".

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Extending QMouseEvent a SECOND time? (within Qt itself)

    Actually I'd do it differently without any need to modify Qt's code. Let's see the current pattern in Qt - we QMouseEvent events that are related to mice and touch screens, we also have gesture events with QGestureEvent and QTouchEvent, tablet events with QTabletEvent and QWheelEvent for the mouse wheel. And of course there are QKeyEvent events for handling the keyboard. You may notice these are all subclasses of QInputEvent. So why not provide another type of event for your input device, implement event translation in the application object (you can subclass QApplication and handle native events as they come) and handle the events either in customEvent() or in event() reimplementations. No need to touch Qt and even if you really want to do that, there is a clean way to do this, simply add another event handler to QWidget API.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2010
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Extending QMouseEvent a SECOND time? (within Qt itself)

    Great reply. But I failed to clarify - I did this for KDE frameworks and desktop, other KDE programmers, and other users of Qt (Not just for an Application of my own.)

    It's done, and coming in Qt 5.0.

Similar Threads

  1. Extending QtTest lib
    By davif in forum Newbie
    Replies: 5
    Last Post: 4th November 2010, 20:45
  2. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 02:59
  3. Extending QGraphicsLayout
    By Darkman in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2009, 13:09
  4. Extending the Diagram Scene Example
    By dosto.walla in forum Newbie
    Replies: 1
    Last Post: 7th October 2008, 19:02
  5. extending QHttp?
    By gfunk in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2007, 09:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.