Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > PyQt4 designer custom properties - combo box style

Reply
Thread Tools

PyQt4 designer custom properties - combo box style

 
 
Andrew
Guest
Posts: n/a
 
      02-02-2010
I am creating custom widgets for the PyQt4 Designer. I can create
custom properties, but I'm looking for how to create a custom property
that has a combo box drop down. I've seen them in the example widgets
and tried following them, but they are using pre-defined items to
populate their property, so it's not a very clear example of how to
get the combo box property to work.

Is there any other examples or help for this kind of setup?

Thanks,
Andrew
 
Reply With Quote
 
 
 
 
David Boddie
Guest
Posts: n/a
 
      02-04-2010
On Tuesday 02 February 2010 22:25, Andrew wrote:

> I am creating custom widgets for the PyQt4 Designer. I can create
> custom properties, but I'm looking for how to create a custom property
> that has a combo box drop down. I've seen them in the example widgets
> and tried following them, but they are using pre-defined items to
> populate their property, so it's not a very clear example of how to
> get the combo box property to work.


Can you explain a bit more about what you have seen and what you are
trying to do. Are you trying to create a property that is treated
specially by Designer or do you want to get the data for the combo
box from somewhere else?

> Is there any other examples or help for this kind of setup?


Have you seen this article?

http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html

David
 
Reply With Quote
 
 
 
 
Andrew
Guest
Posts: n/a
 
      02-06-2010
On Feb 4, 2:59*pm, David Boddie <da...@boddie.org.uk> wrote:
> On Tuesday 02 February 2010 22:25, Andrew wrote:
>
> > I am creating custom widgets for the PyQt4 Designer. I can create
> > custom properties, but I'm looking for how to create a custom property
> > that has a combo box drop down. I've seen them in the example widgets
> > and tried following them, but they are using pre-defined items to
> > populate their property, so it's not a very clear example of how to
> > get the combo box property to work.

>
> Can you explain a bit more about what you have seen and what you are
> trying to do. Are you trying to create a property that is treated
> specially by Designer or do you want to get the data for the combo
> box from somewhere else?


I'm attempting to create a drop down property for a custom widget I'm
creating. So when in designer and you scroll down to the custom
properties, under the regular widget properties, one of them would be
a drop down menu. The data to populate it will be coming from our API
and currently is a list of string-items. Yes, it would be treated
specially by Designer, since it's the only place it would be seen.

In the PyQt4\examples\designer folder, it carries a number of custom
widgets that will load into designer. The datetimeedit widget creates
a custom drop down menu property. The plugin pulls its information
from the QtCore libraries and from the QCalander Widget. Though I am
unable to find a better example or even explanation of how it's
actually creating that drop down menu.

>
> > Is there any other examples or help for this kind of setup?

>
> Have you seen this article?
>
> *http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html


No, I haven't, thanks. That might step in the right direction. I can't
run it right now, so I'm not sure if it is putting a spinbox as it's
property or just the value from the spin box.

>
> David


Andrew
 
Reply With Quote
 
David Boddie
Guest
Posts: n/a
 
      02-06-2010
On Saturday 06 February 2010 10:32, Andrew wrote:

> I'm attempting to create a drop down property for a custom widget I'm
> creating. So when in designer and you scroll down to the custom
> properties, under the regular widget properties, one of them would be
> a drop down menu. The data to populate it will be coming from our API
> and currently is a list of string-items. Yes, it would be treated
> specially by Designer, since it's the only place it would be seen.


Right. The drop down menus in the property editor usually contain values
defined for C++ enums which have been declared to Qt's meta-object system
when a C++ library or plugin is compiled. I'm not sure that PyQt can expose
lists of Python values in the same way.

An example of this is the alignment property in QLineEdit.

> In the PyQt4\examples\designer folder, it carries a number of custom
> widgets that will load into designer. The datetimeedit widget creates
> a custom drop down menu property. The plugin pulls its information
> from the QtCore libraries and from the QCalander Widget. Though I am
> unable to find a better example or even explanation of how it's
> actually creating that drop down menu.


Each of the individual properties are just single values, aren't they, not
collections of values?

>> Have you seen this article?
>>
>> http://qt.nokia.com/doc/qq/qq26-pyqtdesigner.html

>
> No, I haven't, thanks. That might step in the right direction. I can't
> run it right now, so I'm not sure if it is putting a spinbox as it's
> property or just the value from the spin box.


The value from each spin box is turned into a property, so there are
latitude and longitude properties, though each of these only holds
a double precision floating point number. It sounds like you want to be
able to select from a list of values, or possibly change the values
themselves.

If it turns out you can't add a property to Qt Designer in the way you want,
you can still add a custom editor to the widget so that users can open a
context menu and select an item to configure it. This is similar to the way
you can open a dialog to edit the text inside QTextEdit widgets.

The article I referred to also covers this:

http://qt.nokia.com/doc/qq/qq26-pyqt...ml#makingamenu

David
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PyQt4.__file__ gives PyQt4/__init__.py as value wgw Python 1 08-15-2009 09:58 PM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Building Controls 3 07-30-2007 09:09 PM
Designer Property Serialization -- Sycning inner properties to designer property window Alexander Higgins ASP .Net Web Controls 0 07-21-2007 12:58 AM
How to reference one combo box from another combo box SM Javascript 2 04-28-2007 04:49 PM
Fill Combo Box based on another Combo Box dthmtlgod ASP General 1 11-16-2005 04:08 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57