Blog Post

Interrogation with Apport hooks – Qt Included

Earlier today my buddy Martin Pitt blogged about how he needed a Qt developer to work on implementing the ui_question_choice() dialog. I looked through the code a bit this morning, and needed a little help right off the bat getting the GTK version running. One little thing I missed a bug report and Martin helped get it up and running. So as the day went on, storms came through, and for some reason I get in this storm hunter mode and nothing else gets done. Well, about an hour ago all the storms have cleared up and back to work I went. I spent about an hour, most of which was silly Qt Designer and layouts, which Kubuntu guys, I suck at, never listen to me brag about my Qt Designer classes again! The other thing that had me for a second was trying to iterate over a layout to get button statuses. After all was said and done, this is the little beauty that popped up when testing:

apport-qt4

Not to shabby. I will spend some time looking through all of the apport-qt ui stuff and see if I can make it as simple as the GTK side. The checkboxes in that image are generated dynamically by the hook. So once they are added to the layout, trying to figure out their status when they weren’t provided a name was tricky. Thankfully the PyQt 4 API Documentation is great!

So here it is, there is the main dialog and then there is the groupbox with a vertical box inside of it. The vertical box makes it simple to add and remove stuff so that’s why I went that route, KISS. So after the box is populate, you select the stuff you need then press OK to submit it. Well the trick was finding out what is checked. So the main dialog is named dialog and the vertical box that holds the check boxes is called vbox_choices. So here is how I got those values:

result = []
for c in range(0, dialog.vbox_choices.count()):
    if dialog.vbox_choices.itemAt(c).widget().isChecked():
        result.append(c)

So, the main reason for doing this, is so I can find it a bit easier next time, and the fact that I couldn’t find this little bit documented anywhere else. If there is a better way to do this, let me know.

EDIT: Removed the index variable as it was old code left hanging around when I did the copy and paste. Thanks Milian for catching that.

This entry was posted in Application, Development, Linux and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.
  • Archives


semidetached
semidetached
semidetached
semidetached
%d bloggers like this: