[PyQt] QDockwidget advice needed

Hans-Peter Jansen hpj at urpla.net
Wed Aug 18 20:22:36 BST 2010

On Wednesday 18 August 2010, 18:39:31 danny wrote:
> Howdy,
> This is a newbie question. I want to implement the standard paradigm of a
> QTreeView as the central widget in a QMainWindow, and a QDockWidget that
> shows details about the selected item in the tree. I can get the
> QTreeView to work just fine, and I can set up the gui in the QDockWidget
> just fine.
> The question is: what is the standard way to change the contents of the
> dock widget when I change the selected item in the tree.
> My guess is to connect to QTreeView.activated, but what next? From within
> my QTreeView.activated handler do I implement a refresh function that
> changes all the widget values in the dock widget? Is there a slicker way.

You shouldn't need to do this as long as the event loop is kept running.
What kind of widget changes you're talking about?

> Also, if I want the dockwidget to act in a live modeless manner, and have
> the changes propagate between the dock widget and the tree, is there a
> standard paradigm for doing this?

You're modeling the exact reasons of why signals and slots where invented in 
the first place!

As you seem to be in the early stages of approaching Qt, you read Mark 
Summerfields book "Rapid GUI Programming with Python and Qt" already? You 
don't? What a pity. Read it. And no, I'm not affiliated in any way to Mark 
nor P&H, other then I swore, that I will never miss books that he at least 
co-authored anymore. Stop, wrong, two of the "Unsolicited Reader Comments" 
from http://www.qtrac.eu/pyqtbook.html stemming from me (2nd & 3rd). ;-)
I don't say such things lightheaded, BTW.

Next, it's quite helpful to create small test apps, that solely implement 
the detail you're exploring at the moment. You can't imagine, what a few 
lines of code of PyQt can do for you before practicing this. And this adds 
the nice benefit of being exactly what we need anyway to _really_ help you, 
in case you're stuck.


P.S.: You can hire me!

More information about the PyQt mailing list