10-20-2012 01:48 PM
I added the following code:
Page {
Menu.definition: MenuDefinition {
settingsAction: SettingsActionItem {
onTriggered: {
}
}
actions: [
ActionItem {
title: "testingout"
onTriggered: {
}
imageSource: "images/xdarkimage.png"
}
]
}
Container {
..
Code works fine without the menu and doesn't work with it. Gives me the following errorf:
Non-existent attached object
Menu.definition: MenuDefinition {
^)
Is there something I'm missing?
Solved! Go to Solution.
10-20-2012 02:02 PM
10-20-2012 02:11 PM
This is the error message I get in my console (copy/pasted here)
.... Non-existent attached object
Menu.definition: MenuDefinition {
^)
I use
qInstallMsgHandler(myMessageOutput);
so I don't have to use slo2info.
It points me to Menu.definition as seen above. I think its a bug. Checked the code in the api pages and the help in the IDE and both say that is the way to do it. Try copying the above code into a page and see if it works.
10-20-2012 05:35 PM
Add the Menu to the root of your qml page
Use this code:
Menu.definition: MenuDefinition {
// Add a Help action
helpAction: HelpActionItem {
// do something there
onTriggered: {
}
}
// Add a Settings action
settingsAction: SettingsActionItem {
onTriggered: {
//do something here
//like show the settings screen
}
}
}
Reference:
http://cascadescode.tumblr.com/post/32618415391/ma
10-20-2012 06:36 PM - edited 10-21-2012 12:33 PM
Dredvard, what's the rest of the structure of the UI?
It does look like it needs to be in the root, or at least it doesn't seem to work if you have it in a Page which is in a Tab of a TabbedPane.
That said, putting it in a Page within a Tab does not result in the error message you showed. Nor does have a local file called Menu.qml or MenuDefinition.qml, which was one of my guesses. (Edit: Dredvard reports in a later post that he did have a Menu.qml which was causing the problem, so for whatever reason it's not necessarily the case that having such a file will give that error message, but it's probably the case that getting that error message should tell you to look carefully for a Menu.qml file and rename it.)
It does work, so you need to shrink the code down to the simplest thing that reproduces the problem. At that point, you'll likely have found your own solution and can post it here. I just put your code into a simple Page and it works perfectly well...
10-20-2012 09:20 PM - edited 10-20-2012 09:34 PM
Well as far as I can tell I've identified the error is outside of my code- and in the xml files or .pro
I copied the menudef that worked in greenbacks code into mine and got the same error.
I started a new project from scratch copying all the code and assets in... and got the same error.
I then started a new project using a NavigatorPane template and copied the code in and it worked. I then copied my entire source code into the NavigatorPane template and it worked.
I then copied the template base that worked in to my original project and called it from the main... and got the same error!
This is very perplexing. At this point I guess my best option is to start adding permission into the new NavigatorPane template and hopefully it keeps working. I have no idea what is the cause.
Why in some projects does it tell you that fprintf is out of scope in main, (had to include #include <stdio.h>). The two projects that have the error, I don't have to do that include but the one that needs it works. Tried looking at the compiler options and couldn't see anythign different.
Edit: Disregard the above. Just copied the NavPane template qml into the original and the menu pulled down. I'll just keep on deleting and hopefully I figure it out.
10-20-2012 09:43 PM
Ok, the issue is that you can't attach Objects if you use that menu Definition code. How do you attachObjects and use menu defnitions?
10-20-2012 09:48 PM
10-20-2012 10:52 PM
Its actions. Menus can't be used with actionItems.
Wow. That took a while. Try this code:
NavigationPane {
id: navPaneid
Menu.definition: MenuDefinition {
// Add a Help action
helpAction: HelpActionItem {
// do something there
onTriggered: {
}
}
// Add a Settings action
settingsAction: SettingsActionItem {
onTriggered: {
//do something here
//like show the settings screen
}
}
}
Page {
id: pageid
Container {
Label{
text:"testing"
}
}
actions: [
ActionItem {
id: playid
title: "Play"
imageSource: "images/playimage.png"
objectName: "Play"
}
]
}
}
10-21-2012 08:41 AM