Custom widget in Python-Qt, 'live' at Qt Designer

76 views
Skip to first unread message

Pgs Ss

unread,
Jan 5, 2017, 5:10:47 AM1/5/17
to Python GCU Forum
 

I 'm trying to make a custom widget for Qt in Python. I want it, in Qt Designer, to be able to receive events. e.g: (in Qt Designer, at design time) when a textbox is placed within my custom widget, the custom widget to get some attributes from the textbox and make an options list from them.

I 've seen lots of tutorials about extending widgets, making plugins (should I also make a plugin?) but none of them is really complete.


For example, in this tutorial:

1. I have to create some files:

a. The file for the widget:class GeoLocationWidget(QWidget):

b. the file for the plugin: class GeoLocationPlugin(QPyDesignerCustomWidgetPlugin)

c. then it say: For this plugin, we install a task menu extension to let users configure our custom widget on the form via the context menu.

Do I have to install some extension?

I think I don't need a context menu (I suppose it is a menu that shows up with a right click on th widget in QtDesigner)

d. In 'Making a menu' section, I also think this is needed only if I want a Dialog for editing the properties. From what I understand, I can edit the properties of my custom widget from Qt Designer's property editor, right?

e. The file for class GeoLocationMenuEntry(QPyDesignerTaskMenuExtension).


So in fact I need 3 files: a, b, e. Right?


Then it says: ' Unlike C++ plugins, those written in Python do not have to be compiled or otherwise prepared before we install them—we can simply copy the sources to the appropriate locations so that Qt Designer can find them.


So, these 3 files, I 'll have to put them in the 'appropriate locations'. Which re these locations?

I have installed designer.exe (the QtDesigner executable) at: F:\Python34\Lib\site-packages\PyQt4



'The convention for Python plugins is to create a python directory alongside the C++ plugins and store them in there'...

I suppose the directory of C++ plugins is: F:\Python34\Lib\site-packages\PyQt4\plugins

So, I have to create a directory F:\Python34\Lib\site-packages\PyQt4\mycustomplugin?

And which files should I put there?

Reply all
Reply to author
Forward
0 new messages