Qt wrapper around non-Qt class



  • I created a Qt wrapper around a non-Qt class (by composition), basically to implement a GUI/HMI for the class.
    I can easily forward (pass-down) user actions from the Qt wrapper to the non-Qt class, but I can't find an easy and clean way to handle the uiRedraw() event (I mean, redraw the ui only when something changed in the non-Qt class and not on polling base).

    Thank you very much for your support.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Does that non-Qt class offer any feedback mechanism ? e.g. a callback etc.



  • Hi;
    it doesn't offer any callback (at the moment), but I can modify the code, if needed.
    The only restriction is that this class must contain c++ standard code only.
    Could you provide a link on how to add a feedback mechanism?


  • Lifetime Qt Champion

    It depends a bit on the design of your other classes. They could also use some sort of IPC channel like sockets to communicate etc.

    What are these classes doing that you are writing a wrapper for ?



  • The classes implement a state machine with some input methods/commands (used to control the state machine itself).
    Some of the states produce or update data and I've already implemented an observer pattern to notify other classes for new data availability.
    Maybe this internal observer pattern can be used to notify somehow the wrapper too, but I can't find a way (I'm not an expert of Qt).


  • Qt Champions 2016

    @-vix- said in Qt wrapper around non-Qt class:

    Maybe this internal observer pattern can be used to notify somehow the wrapper too, but I can't find a way (I'm not an expert of Qt).

    Can't you push an observer from the Qt code by which to monitor the non-Qt code, which (observer) in turn would call the QWidget::update or raise a signal or something?



  • @kshegunov said

    Can't you push an observer from the Qt code by which to monitor the non-Qt code, which (observer) in turn would call the QWidget::update or raise a signal or something?

    This can be a good idea; I need some time to expose to the Qt wrapper the methods to attach is as an observer.


Log in to reply
 

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