[PyQt] Re: connection between 2 widget
Massimo Di Stefano
massimodisasha at yahoo.it
Wed Jun 24 10:45:48 BST 2009
thanks for point me on how to solve my problem :-)
i know it is not only a pyqt ... biut more related to programming,
i'm a poor self teached student thanks for your example i'm now able
to go ahead
with my code!
now i'm coonecting :
doublespinbox using :
SIGNAL("valueChanged(double)"), self. external_class.setSpinBoxValue)
linEdit using :
now looking for combo-box widget too.
Il giorno 22/giu/09, alle ore 20:01, David Boddie ha scritto:
> On Sun Jun 21 17:37:54 BST 2009, Massimo Di Stefano wrote:
>> I'm tring to get a solution,
>> i searced for similar code in the pyqt examples source code
>> but i can't find nothig similar.
>> is the question i proposed comprensible?
> It's a little difficult for me to understand, but I'll try and work
> it step by step:
>> i can reproduce my problem with an example :
>> W-1 (spinbox + button) [ it is a main app, and has in the menu bar
>> an action to open W-2]
> OK, I see this in your example.
>> W-2 (line edit + button)
> Right. I see this when I select the process->run menu item.
>> i run W-1, pressing its button it increase the spinbox value,
>> then pressing the action from the menu -> open W-2
> Yes, these work as expected. A question: what happens if the user
> the value in the spin box directly?
>> W-2 , at its start, read value from W-1 -- pressing the W-2 button
>> process W-1 value and print it .
> When I click the button, I see the value from the spin box in the line
>> my problem :
>> i need that everitime i change the W-1 value ...
>> ... when i press button in W-2 it will process the W-1(changed
> OK, so instead of passing a value when you create W-2, you want the
> to be taken from the spin box in W-1 and written to the line edit?
> Here are some changes I made to your code to do what I think you want.
> Firstly, I create the Elab widget in the init() method of your
> class instead of creating it later in the elaborazione() method.
> This makes
> it possible for me to connect a signal from the ZoomSpinBox to a
> slot in
> the widget.
> def init(self):
> self.w = GuiWidget()
> self.Value = 0
> self.query = Elab()
> self.connect(self.w.p1, SIGNAL("clicked()"), self.inc)
> self.connect(self.w.actionRun, SIGNAL("triggered()"),
> def elaborazione(self):
> I just show the Elab widget when the elaborazione() method is called.
> In the Elab class, we no longer need to pass an initial value, but
> you could
> make the class take a value to begin with if you want. We don't want
> to show
> the widget immediately, so I removed a call to its show() method.
> class Elab(QWidget, Ui_Form):
> def __init__(self):
> self.value = 0
> self.connect(self.p2, SIGNAL("clicked()"),self.elabora)
> def elabora(self):
> newvalue = str(self.value)+str('-----')
> print newvalue
> def setValue(self, value):
> self.value = value
> I added the setValue() slot that we used in the app.py file. This
> updates the
> value held by this widget so that clicking the button causes an up-
> value to be used.
> Is this what you had in mind?
> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt