1

I am creating an application with PyQt4 and I want to use qtDesigner to design the layout. The application contains a QGraphicView, for which I want to implement panning and zomming per mouse. The only way I know how to do that is deriving from QGraphicView overwriting the "mouse*" functions to do the panning and zooming.

Now I want to use this new custom widget with qtdesigner.

googling I find that I could write a "custom widget plugin" for qtdesigner. While it does not seem to be to difficult, I still find it overkill for such a little adjustment I want to make.

What other ways are there to customize a widget in PyQt4 when the layout is done with qdesigner?

Thanks!

2
  • 2
    Why not just design the ui using Qt Designer, then put the code for your mouse functions in your subclass that inherits the ui class? Jun 14, 2011 at 22:05
  • 1
    I am not sure how to do that. I would get all mouse messages for the application, in that case. How would I filter the mouse events going to the graphicsview?
    – Nathan
    Jun 15, 2011 at 6:27

1 Answer 1

6

You can promote your QGraphicsView to your own subclass In the designer, right click on the QGraphicsView and select "Promote To" and fill the dialog with relevant information about your own subclass:

PromoteWidget

2
  • My version of Qt designer automatically wants to create a header file with .h extension, I assume because is a C++ header file, but in your image says ".Module". Do you just rename it or automatically propose you that "pyQT" friendly name? And it creates you a valid Module file for PyQT? Feb 2, 2015 at 8:25
  • I create a class in a desired module and then specify the module's name in "Header file:" field
    – Winand
    Apr 6, 2015 at 6:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.