[Qt-interest] Signal-Slot not working

Timothy Greaves tgreaves21227 at yahoo.com
Fri Mar 27 18:57:09 CET 2009


Did you declare the signal and slot in your header?

"John Smith" <invalid at example.com> wrote in message 
news:gq8gl7$egt$1 at eple.troll.no...
> "Martin Fiala" <fialkam at gmail.com> wrote in message 
> news:b7e0f19a0903230334i78eee280l805b1a3456c56820 at mail.gmail.com...
>>I don't really clearly understand.. But to me it looks like
>> "contactos_created" stays false all the time..
>> If you want to change it, you could assign it after creating the
>> newForm, where it sems logical to be set to true...
>> But it surely doesn't explain why the program finishes unexpectedly...
>>
>> On Sun, Mar 22, 2009 at 8:15 PM, algajard <algajard at gmail.com> wrote:
>>> Hey list,
>>>
>>> I've a problem with signals and slots. I created a signal for a QWidget
>>> for closing and a slot in other QWidget with a slot that receive this
>>> signal and update somes inner states. The problem is that apparently the
>>> signal is not recieved by the slot.
>>>
>>> Here is the signal
>>>
>>>
>>> void ContactosForm::closeEvent(QCloseEvent *event)
>>> {
>>> emit closing();
>>> event->accept();
>>> }
>>>
>>> Here is the slot (is a private slot).
>>>
>>> void ClientesForm::contactos_closing()
>>> {
>>> this->contactos_created=false;
>>> }
>>>
>>> and this is the Constructor of the second widget.
>>>
>>> ClientesForm::ClientesForm(QWidget *parent) :
>>> QWidget(parent){
>>> setupUi(this);
>>> contactos_created=false;
>>> newForm=new ContactosForm;
>>> connect(newForm,SIGNAL(closing()),this,SLOT(contactos_closing()));
>>> }
>
> Also, check the return value of connect
>
> bool b = 
> connect(newForm,SIGNAL(closing()),this,SLOT(contactos_closing()));
> assert(b);
>
>
> 





More information about the Qt-interest-old mailing list