简体   繁体   中英

Qt Maps (QML) application window is blank

This is my code for a Qt Maps application I'm trying to make. http://pastebin.com/PNcYivM9 - main.qml

I'm using Qt Creator on Ubuntu 14.04. When I do compile and run the code the application window is blank.

I haven't edited the main.ui.qml apart from adding the Qt Location import.

I've also added the location keyword in the .pro file Any help would be appreciated since I can't really find any tutorials on maps.

EDIT: Here's the code

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtLocation 5.4

ApplicationWindow {
    title: qsTr("Hello World")
    width: 640
    height: 480
    visible: true


    Plugin{
        id: osmplugin
        name:"osm"
    }

    Map {
        plugin: osmplugin

        id: map
        zoomLevel: (maximumZoomLevel - minimumZoomLevel)/2


//        center {
//            latitude: -27.5796
//            longitude: 153.1003
//        }

        // Enable pinch gestures to zoom in and out
        gesture.flickDeceleration: 3000
        gesture.enabled: true

//    center {
//        latitude: -27.5796
//        longitude: 153.1003
//    }
    }




}

Your Map has no dimensions set, so it's going to default to a width and height of zero. To see that this is the case, add the following to your Map component:

Component.onCompleted: {
    console.log("Dimensions: ", width, height)
}

This will print out:

Dimensions: 0 0

So you either need to set the dimensions to a value other than zero, or use the anchor property to attach the dimensions to the parent's anchors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM