Qt new style signals/slots

Dirk Hohndel dirk at hohndel.org
Sat Jan 18 22:14:32 PST 2020

On my phone.
The first 'this' is wrong. That needs to be the address of the specific qdatetomeedit in the UI.
My mistake


On January 18, 2020 9:32:43 PM PST, Willem Ferguson <willemferguson at zoology.up.ac.za> wrote:
>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
>>> 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
>>> 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, 
>/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, 
>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
>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, 
>I just do not know how to proceed.
>Kind regards,
>This message and attachments are subject to a disclaimer.
>Please refer to 
><http://upnet.up.ac.za/services/it/documentation/docs/004167.pdf> for

From my phone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20200118/b3d4c3a1/attachment.html>

More information about the subsurface mailing list