PyQt Tips and Tricks

(Tips and Tricks)
(Tips and Tricks)
Line 14: Line 14:
The second and more general solution is to use the [http://pysnippet.blogspot.com/2010/06/qsignalmapper-at-your-service.html QSignalMapper]
The second and more general solution is to use the [http://pysnippet.blogspot.com/2010/06/qsignalmapper-at-your-service.html QSignalMapper]
 +
 +
== Learning to use Qt CSS ==
 +
 +
Much like web development, [http://doc.qt.nokia.com/4.6/stylesheet.html CSS is also available within Qt]. [http://doc.qt.nokia.com/4.6/stylesheet-examples.html There's a list of examples] that can be tried out just using Qt Designer. If you're using custom CSS, using [http://agateau.wordpress.com/2008/01/15/qt-stylesheets-and-qpalette/ palette() in your CSS definitions] will allow you to use colors that the theme already knows about. As an example, this is an easy way to get the default blue color on your buttons when you want that color.
 +
 +
Depending on your needs, there's a number of [http://doc.trolltech.com/4.4/stylesheet-reference.html#list-of-icons built-in icons] that are available for use.
= Example Applications =
= Example Applications =

Revision as of 14:39, 16 June 2010

With Meego there is a lot of interest in developing applications in Qt rather than GTK. This page spawned from a discussion thread.

Contents

Tips and Tricks

Identifying the Sender of a Signal

There are two main approaches for this. The first is to wrap the slot with a lambda to pass in any additional arguments

def notifyMe(foo)
  print foo
x = lambda: notifyMe("they call him tim")
self.connect(b, SIGNAL("clicked()"), d.close)
self.connect(f, SIGNAL("clicked()"), x)

The second and more general solution is to use the QSignalMapper

Learning to use Qt CSS

Much like web development, CSS is also available within Qt. There's a list of examples that can be tried out just using Qt Designer. If you're using custom CSS, using palette() in your CSS definitions will allow you to use colors that the theme already knows about. As an example, this is an easy way to get the default blue color on your buttons when you want that color.

Depending on your needs, there's a number of built-in icons that are available for use.

Example Applications

Web Resources