2013-05-09 149 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') 
        } 
       } 
相關問題