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
Contributor
raclausi
Posts: 10
Registered: ‎03-10-2013
My Device: playbook, BOLD 9780, Z10
My Carrier: fido
Accepted Solution

C++ access to a textbox created in C++...no qml in sight...

Greetings to all.. I have just joined the community...and I have just received a dev alpha--- I have been able to upload a few crude samples to experiment with onto that device... I can write to a text or label box but i seem to be unable to read from a text box... I have tried using the connect command as shown in the lightening example

bool result = QObject::connect(opacitySlider, SIGNAL(immediateValueChanged(float)),day,SLOT(setOpacity(float)));

and although i have a syntax error on this line, it does run nicely...

but i get a polite message that i am using an illegal void in variations of

connect (textfield, SIGNAL(textChanging(const Qstring &)), this, SLOT (onTextChanging(const QString &)));

 

I would love to just be able to do a strcpy( mystring, textfield.text)  ..is such a simple thing possible..????

I am assuming "this" and "&" are signature tokens that pass parameters within the connect???

I would like to avoid qml intra-coding if i can... so if someone can give me a good shove in the right direction, i would be grateful... Is there a reference manual online dealing with these c++ extensions??? cheers, rich

Please use plain text.
Developer
Zmey
Posts: 1,505
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: C++ access to a textbox created in C++...no qml in sight...

[ Edited ]

Hi! Welcome to the forums.

Signals & slots are Qt concept.

To get the text from textfield you can simply call text() method:
QString someString = textfield->text();

textChanging signal is for monitoring textfield changes.

Be careful not to make a typo when connecting signals to slots. In the line above you have Qstring instead of QString.

"&" is C++ reference. It's ignored in SLOT() and can be omitted there.

I suggest reading a Qt tutorial or a book because Cascades are based on Qt.

Also Cascades have excellent C++ API so using QML for creating the UI is optional.

Docs are located here:

https://developer.blackberry.com/cascades/documentation/

The examples are on github:

https://github.com/blackberry/Cascades-Samples

Qt docs for signals & slots:

http://qt-project.org/doc/qt-4.8/signalsandslots.html


A better forum section for this is Cascades one.


Andrey Fidrya, @zmeyc on twitter
Please use plain text.
Contributor
raclausi
Posts: 10
Registered: ‎03-10-2013
My Device: playbook, BOLD 9780, Z10
My Carrier: fido

Re: C++ access to a textbox created in C++...no qml in sight...

thank you for the quick response..hmmmm...this and several permutations of it  doesn't work, eh...
        QString somestring=textField->text();   compiles ok
                     textField2->setText(somestring); compiles ok but no effect... blanks or leaves unchanged depending on perm


and this line really gets angry at me..
 strcpy(thisline, textArea->text());
char and QString are not compatible... is there a type casting of some sort here...


Although I have  printed and read the cascades doc, s closely, I will need to track down a QT manual..  is there an obvious  bug above

rich

Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: C++ access to a textbox created in C++...no qml in sight...

If you really need get char* from QString then you can do it following way (assuming thisline is of type char* and enough memory is allocated):

QByteArray byteArray =  textArea->text().toUtf8();
strcpy(thisline, byteArray.constData());

 

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: C++ access to a textbox created in C++...no qml in sight...

[ Edited ]

Just a note that BlackBerry advise you not to do this to avoid security issues, better to leave the text in the QString or QByteArray.

 

http://developer.blackberry.com/cascades/documentation/dev/security/index.html#wba1358262187373


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Contributor
raclausi
Posts: 10
Registered: ‎03-10-2013
My Device: playbook, BOLD 9780, Z10
My Carrier: fido

Re: C++ access to a textbox created in C++...no qml in sight...

Thank You very much for your kind help. It has been quite a week and learning curve.... I appreciate the very good advice I received from you... Since I am just acclimatizing myself to this environment, I am building from what I know ie C ..... the development environment is different from what I am used to..but the plus of having problems is the need to crawl around the innards of the development framework. I will need to dig thru QT and the nifty code extensions to C that it represents... I have one more problem I am resolving but I think I will give it a go using the resources you have directed me to. I hope I can return the favour at some point. Again, cheers and thanks, rich

Please use plain text.