Hi Willem,

> On Jan 18, 2020, at 3:48 AM, Willem Ferguson 
> <[email protected]> wrote:
> 
> Following excellent review of a recent PR, I was asked to update the 
> conventional string-based Qt connections to the new-style Qt connections. 
> (https://wiki.qt.io/New_Signal_Slot_Syntax 
> <https://wiki.qt.io/New_Signal_Slot_Syntax>) The old style is: 
> 
> connect(
>     sender, SIGNAL( valueChanged( QString, QString ) ),
>     receiver, SLOT( updateValue( QString ) )
> );
> My old-style connection is:
> 
> connect(ui.timeDiffEdit, SIGNAL(timeChanged(const QTime)), this, 
> SLOT(timeDiffEditChanged()));
> 
> For the new style the specification in the Qt documentation is:
> 
> connect(
>     sender, &Sender::valueChanged,
>     receiver, &Receiver::updateValue
> );

So as you see here, the documentation wants you to use the function address as 
argument...
> 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 from 
> timeDiffEdit->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. For completeness I attach the code for the full 
> object to this email.
> 
> 


How about  

connect(this, &QTimeEdit::timeChanged, this, &ImportGPS::timeDiffEditChanged);

That seems like it would follow the syntax suggested above, right?

/D
_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to