09-17-2012 02:58 AM
Hi,
So I need to do something when I press on the ActionItem in the swipe down context menu on BB10.
I created the swipe down menu
Menu *menu = Menu::create();
Image infoIcon = Image(QUrl("asset:///images/info"));
menu->addAction(ActionItem::create().title("Info") .image(infoIcon));
menu->setObjectName("infoItem");
Looked at the docs. AbstractActionItem
https://developer.blackberry.com/cascades/referenc
The action item emits a triggered() Signal.
Then ran info a bunch of issue which didn't help.
in my App.hpp file I added
public: void debugText();
I tried connecting the menu using the following code:
connect(menu->objectName(), SIGNAL(triggered()), this, SLOT(debugText()));
It doesn't work, and I spent 2 hours trying to figure out why not.
How do you actually connect these things?
Thanks!
Do people really want their phone making decisions for them? Whatever happened to the human element? Stop this madness!
Solved! Go to Solution.
09-17-2012 04:10 AM
Hi,
triggered signal is attach to ActionItem itself and not Menu object.
And don't forget Q_SLOT macro.
class xxx : virtual QObject {
Q_OBJECT
public:
Q_SLOT void debugText(void);
};
Menu *menu = Menu::create();
Image infoIcon = Image(QUrl("asset:///images/info"));
ActionItem *mItem = ActionItem::create().title("Info").image(infoIcon)
menu->addAction(mItem);
menu->setObjectName("infoItem");
connect(mItem, SIGNAL(triggered()), this, SLOT(debugText()));
Nicklas
09-17-2012 11:05 AM - edited 09-17-2012 11:06 AM
take a look at my Open Source project
https://github.com/blackberry/opendataspace-cascad
Inside ...app.cpp you'll find the code to create an ApplicationMenu with some Actions and Howto connect the Actions with your code.
In my case I'm using Sheets to be displayed.
if you have any questions: I'm in San Jose next week
09-17-2012 01:08 PM
Ok. The code from nicklas worked. I was missin "Q_SLOT" type declaration in my header file.
Thank you nicklas, and ekke!![]()
Do people really want their phone making decisions for them? Whatever happened to the human element? Stop this madness!