[SOLVED] Wiring different events inside QFrame
-
Hello Qt community.
I'm new to Qt, so if I wrote on wrong forum or anything, please pardon me. Also, I have tried googling help to this, but I couldn't find any.
Anyway, I created simple ui with interface designer, which only has 1 frame and 3 push buttons inside. I wanted to add different click events to these buttons (for starters, 1st button should print 1, 2nd 2, etc..).
However, my code manages to wire these events to function i want, but all there buttons print 3 (last value of i). How can I solve this issue ?
Btw, my original problem is to have way to add any number of nodes (let them be buttons for now) to UI, than read them inside code and apply some logic to them. I want to use this to model DFA and do some simple animation when transitioning states. Is there maybe better way to solve this (with Qt and Python) ?
Thanks in advance,
Ajdin -
Hi and welcome
This forum is mostly c++ but I assume some also use python.
There is also
https://forum.qt.io/category/15/language-bindings
Where more python seems to hang out.
So if not lucky here then also try there :)I have never used Python, but I wondered about the syntax for the lambda as it seems you
reference external function (f). Will It will still create an inline version for each invocation ? (for all children)Anyway, when a signal is send (like clicked), you can get the sender
def buttonClicked(self):
sender = self.sender()so you should be able to hook your DFAWidget up in a dynamic fashion and
then let the class do what you want when transitioning.
That said, did you see QML ?
http://doc.qt.io/qt-5/qtqml-index.html
Very easy to get animation up an running.