Qt new style signals/slots
Willem Ferguson
willemferguson at zoology.up.ac.za
Sat Jan 18 21:32:43 PST 2020
On 2020/01/18 21:32, Dirk Hohndel wrote:
> Hi Willem,
>
>> On Jan 18, 2020, at 3:48 AM, Willem Ferguson
>> <willemferguson at zoology.up.ac.za
>> <mailto:willemferguson at zoology.up.ac.za>> wrote:
>>
>> My formulation, reflecting my strong deficiencies in Qt coding but
>> following the above, for the new connection is:
>>
>> connect(this,
>> ui.timeDiffEdit->timeChanged(ui.timeDiffEdit->time()),this,
>> this->timeDiffEditChanged());
>>
>> The second parameter needs to be a pointer, for which I used
>> ui.timeDiffEdit. The timeChanged() signal needs a QTime value, so I
>> provided that with ui.timeDeffEdit->time(), the actual amount of time
>> by which the timeDiffEdit has been changed.
>>
>> The last parameter also needs an address, provided by
>> this->timeDiffEditChanged() is the response to the signal
>> fromtimeDiffEdit->timeChanged(). It is a void function and the source
>> of build problems. The compiler generates an error:
>>
>> /home/willem/src/subsurface/desktop-widgets/importgps.cpp:30:104:
>> error: invalid use of void expression
>> connect(this, ui.timeDiffEdit->timeChanged(ui.timeDiffEdit->time()),
>> this, this->timeDiffEditChanged());
>> ^
>>
>> Obviously, accessing the pointer this->timeDiffEditChanged() should
>> not return a void value. I have no idea of how to respond to this
>> error. Any suggestions are very welcome.
>>
>
>
> How about
>
> connect(this, &QTimeEdit::timeChanged, this,
> &ImportGPS::timeDiffEditChanged);
>
> That seems like it would follow the syntax suggested above, right?
>
> /D
Thank you very much for your time.
For Dirk's suggestion I get:
/home/willem/src/subsurface/desktop-widgets/importgps.cpp: In
constructor ‘ImportGPS::ImportGPS(QWidget*, QString,
Ui::LocationInformation*)’:
/home/willem/src/subsurface/desktop-widgets/importgps.cpp:30:78: error:
no matching function for call to ‘ImportGPS::connect(ImportGPS*, void
(QDateTimeEdit::*)(const QTime&), ImportGPS*, void (ImportGPS::*)())’
connect(this, &QTimeEdit::timeChanged, this,
&ImportGPS::timeDiffEditChanged);
^
I suspect this means that there is a problem in the types of parameters
in the call to connect() ??
For Bill's formulation there is an apparent problem with the signal part
of the call to connect():
/home/willem/src/subsurface/desktop-widgets/importgps.cpp:31:88: error:
invalid use of non-static member function ‘void
QDateTimeEdit::timeChanged(const QTime&)’
connect(ui.timeDiffEdit, ui.timeDiffEdit->timeChanged, this,
this->timeDiffEditChanged)
^
I just do not know how to proceed.
Kind regards,
willem
--
This message and attachments are subject to a disclaimer.
Please refer to
http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf
<http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf> for
full
details.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20200119/d97b9e75/attachment.html>
More information about the subsurface
mailing list