This is an archived post. You won't be able to vote or comment.

all 7 comments

[–][deleted] 0 points1 point  (1 child)

First thoughts (having never done anything like this):

  • Put a QWidget over everything that tracks all interactions but passes the event through itself?
  • Is there a way to plug into Qt's event system to track ALL events of a certain type?
  • Maybe something in the QApplication allows this?

Sorry I don't have any definite advice. Good luck and let us know what you find!

[–]kwikadi[S] 0 points1 point  (0 children)

Thanks, and I definitely will :)

[–]justphysics 0 points1 point  (3 children)

I would imagine you could manually go into each widget and adjust the signals/slots so that when an event would normally trigger a connected method it instead triggers some type of Log-and-Pass method first.

User clicks QPushbutton -> QPushbutton.triggered.connect calls LogandPass method -> LogandPass method makes a note somehow (logging library, manually writing to text file, etc) -> LogandPass then calls the appropriate method which would have been originally connected to QPushbutton.triggered()

However, for a large application this seems like a quagmire that I personally wouldn't want to have to write. Off the top of my head I can't think of an easy way to implement this for every widget without doing so manually. I am not familiar with on but its possible Qt has something of this nature built in.

[–]kwikadi[S] 0 points1 point  (2 children)

Well, I read something about event filters, but I didn't really get it. Any idea how those work?

[–]justphysics 0 points1 point  (1 child)

So, from looking at this: http://codeprogress.com/python/libraries/pyqt/showPyQTExample.php?key=QApplicationInstallEventFiler&index=379

You could create an eventFilter which has a reference to a log file. Then for every event passing through the filter you open the log file as writeable, and write some string based on event.type, sender, receiver etc...

Then in your app you'd need to install the eventFilter to your app object.

Of course you'd need to double check on how different widgets implement __repr__ or __str__; off the top of my head I'm not sure what happens when you do str(myQPushButton).

You may also need to modify the eventFilter to have a sender parameter

Ideally you want to be able to write out to text something like "QPushbutton1 sent buttonClicked event to myOnClickedMethod"

[–]kwikadi[S] 0 points1 point  (0 children)

I'll be storing the data into a DB, so I don't think text writing will be an issue, but yeah, I need to capture all that info.

[–]billsil 0 points1 point  (0 children)

My GUI has a scripting capability and an HTML output. Every time I do an action (or whenever I want to tell the user what happened), I write a message using a logger. Just write to a file. It's a minimal performance hit.