• 3931阅读
  • 3回复

[提问]关于url的问题 [复制链接]

上一主题 下一主题
离线lovexin109
 

只看楼主 倒序阅读 楼主  发表于: 2015-10-30
想用TABVIEW为下面的每个按钮做不同的图片,在TAB中增加了一个属性string型用来存放背景图片,结果不论是string  或者 url 都不行,报错

qrc:/main.qml:77:20: Unable to assign [undefined] to QUrl
qrc:/main.qml:77:20: Unable to assign [undefined] to QUrl
qrc:/main.qml:77:20: Unable to assign [undefined] to QUrl
qrc:/main.qml:77:20: Unable to assign [undefined] to QUrl
qrc:/main.qml:77:20: Unable to assign [undefined] to QUrl







TabPlus如下
import QtQuick 2.0

import QtQuick.Controls 1.3

Tab{
    property string tabpressed
}


main中如下

import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.1

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

    TabView{
        tabPosition: Qt.BottomEdge
        anchors.fill: parent
        anchors.centerIn: parent
        style:styletab

        TabPlus{
            title: "view1"
            Page1{ visible: true }
           tabpressed:"images/tab_selected.png"
        }        TabPlus{
            title:"view2"
            Page2{ visible: true }
            tabpressed:"images/button_default.png"
        }
        TabPlus{
            title: "view3"
            Page3{ visible: true }
            tabpressed:"images/tab_selected.png"

        }
        TabPlus{
            title: "view3"
            Page4{ visible: true }
           tabpressed:"images/tab_selected.png"
        }

    }

Component{
    id:styletab
    TabViewStyle{
        tabsAlignment: Qt.AlignHCenter
        tabOverlap: 0
    tab: Item{
        implicitWidth:control.width/control.count
        implicitHeight:50

       BorderImage {
           anchors.fill: parent

           source :styleData.tabpressed
           border.top: 8
           border.bottom: 8
           Text{
               anchors.centerIn: parent

               color: styleData.selected ? "white":"blue"
               text: styleData.title
               font.pixelSize: 16
           }

        }

    }

}
    }
}


不知道为什么这样,希望指点一下如何更改
离线toby520

只看该作者 1楼 发表于: 2015-10-30
参考 [http://www.heilqt.com/](http://www.heilqt.com/)
QtQML多多指教开发社区 http://qtclub.heilqt.com
将QtCoding进行到底
关注移动互联网,关注金融
开发跨平台客户端,服务于金融行业
专业定制界面
群号:312125701   373955953(qml控件定做)
离线lovexin109

只看该作者 2楼 发表于: 2015-10-30
回 toby520 的帖子
toby520:参考 [http://www.heilqt.com/](http://www.heilqt.com/) (2015-10-30 17:03) 

谢谢版主,还没找到相关的例子,是在外面不能使用增加的属性吗?我感觉不是类型错了,感觉像是格式不对
离线lovexin109

只看该作者 3楼 发表于: 2015-11-01
回 toby520 的帖子
toby520:参考 [http://www.heilqt.com/](http://www.heilqt.com/) (2015-10-30 17:03) 

styleData根本没那么多属性,自定义的更没有,所以才报这样的错吧
快速回复
限100 字节
 
上一个 下一个