Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
javoid
Posts: 189
Registered: ‎11-24-2012
My Carrier: NA
Accepted Solution

ToggleButton slots signal problem

Trying to connect a signal to a slot:

 

connect(myToggleButton, SIGNAL(checkChanged(bool)), myDataClass, SLOT(setMyValueOn(bool)));

 In myDataClass.hpp:

public slots:
  void setMyValueOn(bool valueOn);

 In the cpp file:

void MyDataClass::setMyValueOn(bool valueOn)
{
  // never called
}

 I've the MyDataClass is a subclass of QObject and has Q_OBJECT in the appropraite place in the hpp file.

 

I think I'm using the toggle switch incorrectly.

 

 

Please use plain text.
Developer
Zmey
Posts: 1,494
Registered: ‎12-18-2012

Re: ToggleButton slots signal problem

The signal is called checkedChanged(bool). :smileyhappy:

 

Btw I suggest using Qt Creator if you're developing mostly in C++. It has very convenient signals autocompletion feature. 

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
javoid
Posts: 189
Registered: ‎11-24-2012
My Carrier: NA

Re: ToggleButton slots signal problem

[ Edited ]
The signal is called checkedChanged(bool)

oh, jeez. :Rolleyes:

This stopped my work last night.  Would be nice if it let us know the signature is incorrect when building.

 

QT Creator: Are you referring to this one:

http://qt-project.org/downloads

 

Or something made from BB?

 

Also, does onCheckedChanged() emit a signal, or only checkedChanged(bool)?

Please use plain text.
Developer
Zmey
Posts: 1,494
Registered: ‎12-18-2012

Re: ToggleButton slots signal problem

[ Edited ]

QT creator: yes. It's a pain to setup but speeds up the development considerably. It's very lightweight and fast, has better Qt classes support, can compile multiple files in parallel. Even deployment is faster somehow.

 

Version 2.6+ has QNX plugin (it's enabled by default) which allows deploying to BB10. It works with Cascades, haven't tried to setup QML though. And there is no preview support for QML.

 

I'm using it on MacOS. There were problems on Windows, but didn't investigate them. Maybe I made a mistake during setup.

 

Setup instructions:

http://qt-project.org/wiki/Qt-Creator-with-BlackBerry-10

 

p.s. I think the signal is checkedChanged(bool) only but in slot you can omit arguments.

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Developer
javoid
Posts: 189
Registered: ‎11-24-2012
My Carrier: NA

Re: ToggleButton slots signal problem

I saw the onCheckedChanged() method and thought it could be used; that also threw me for a loop yesterday.

 

One last thing, in the class destructor, is it necesary to disconnect signals, or does this process happen automatically?

Please use plain text.
Developer
Zmey
Posts: 1,494
Registered: ‎12-18-2012

Re: ToggleButton slots signal problem

[ Edited ]

It happens automatically, but in some cases (multithreaded apps) deleteLater() is needed. Check QObject::~QObject description at http://doc.qt.digia.com/qt/qobject.html for details.

 


Andrey Fidrya, @zmeyc on twitter
Please use plain text.