2013-05-09 154 views
0

当我尝试显示对话框或选项卡中的弹出窗口时出现此错误。我不明白为什么。在我制作的其他应用程序中,它可以工作,但我无法看到它们之间的差异。错误:无法将QObject *分配给QQuickItem *

我在做什么错?

我由具有完全相同的问题的示例代码:

import QtQuick 2.0 
import Ubuntu.Components 0.1 
import Ubuntu.Components.ListItems 0.1 as ListItem 
import Ubuntu.Components.Popups 0.1 
MainView { 
// objectName for functional testing purposes (autopilot-qt5) 
objectName: "mainView" 

// Note! applicationName needs to match the .desktop filename 
applicationName: "testar" 

/* 
This property enables the application to change orientation 
when the device is rotated. The default is false. 
*/ 
automaticOrientation: true 

width: units.gu(50) 
height: units.gu(75) 

Tabs { 
    id: tabs 

    // First tab begins here 
    Tab { 
     objectName: "Tab1" 

     title: i18n.tr("Hello..") 

     // Tab content begins here 
     page: Page { 
      Column { 
       width: parent.width 
       ListItem.Standard { 
        text: i18n.tr("Swipe from right to left to change tab.") 
       } 
      } 
      // coordinates popover 
      Component { 
        id: popoverComponent 

        Popover { 
         id: popover 
         Column { 
          id: containerLayout 
          anchors { 
           left: parent.left 
           top: parent.top 
           right: parent.right 
          } 
          ListItem.Header { text: "Standard list items" } 
          ListItem.Standard { text: "Do something" } 
          ListItem.Standard { text: "Do something else" } 
          ListItem.Header { text: "Buttons" } 
          ListItem.SingleControl { 
           highlightWhenPressed: false 
           control: Button { 
            text: "Do nothing" 
            anchors { 
             fill: parent 
             margins: units.gu(1) 
            } 
           } 
          } 
          ListItem.SingleControl { 
           highlightWhenPressed: false 
           control: Button { 
            text: "Close" 
            anchors { 
             fill: parent 
             margins: units.gu(1) 
            } 
            onClicked: PopupUtils.close(popover) 
           } 
          } 
         } 
        } 
       } 

      tools: ToolbarActions { 
       // Show spawn again 
       Action { 
        objectName: "action1" 
        id: action1 

        iconSource: Qt.resolvedUrl("toolbarIcon.png") 
        text: i18n.tr("Reload") 

        onTriggered: { 
         console.debug('Debug: Reload data') 
         PopupUtils.open(popoverComponent, action1) 
        } 
       } 
     } 
     } 
    } 

    // Second tab begins here 
    Tab { 
     objectName: "Tab2" 

     title: i18n.tr("..Toolbar!") 
     page: Page { 
      tools: ToolbarActions { 
       Action { 
        objectName: "action" 

        iconSource: Qt.resolvedUrl("toolbarIcon.png") 
        text: i18n.tr("Tap me!") 

        onTriggered: { 
         label.text = i18n.tr("Toolbar tapped") 
        } 
       } 
      } 

      Column { 
       anchors.centerIn: parent 
       Label { 
        id: label 
        objectName: "label" 

        text: i18n.tr("Swipe from bottom to up to reveal the toolbar.") 
       } 
      } 
     } 
    } 
} 

}

回答

0

我得到它的工作!事情是,我试图通过点击工具栏来显示对话框,或者其他任何东西 - 这是别的东西,然后是实际窗口中的其他东西。

因此,我只是将工具栏上的标识更改为窗口中的某个项目,在这种情况下,这是一个带有id:owMap的WebView。旧ID是一两排并注释掉。

现在它的工作!

   // Change coordinates 
       Action { 
        id: coordinateAction 
        objectName: "action2" 

        iconSource: Qt.resolvedUrl("toolbarIcon.png") 
        text: i18n.tr("Coordinates") 

        onTriggered: { 
         //PopupUtils.open(dialog, coordinateAction) 
         PopupUtils.open(cooDialog, owMap) 
         console.debug('Debug: Change coordinates pressed') 
        } 
       } 
相关问题