Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Image not loading
QtWS25 Last Chance

Image not loading

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
embedded qtraspberry pi 3bwatchqt6.5.0
3 Posts 3 Posters 545 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Raghav
    wrote on last edited by
    #1

    Hi,
    I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to load

    Here is my QML code:

    import QtQuick
    import QtQuick.Window
    import QtQuick.Layouts 1.15
    import QtQuick.Controls 2.15
    
    Window {
        width: 240
        height: 240
        visible: true
        color: "transparent"
        maximumHeight: 240
        maximumWidth: 240
        minimumHeight: 240
        minimumWidth: 240
    
        Rectangle{
            id: circular_area
            height: parent.height
            width: parent.width
            radius: parent.width / 2
            color: "black"
        }
    
        SwipeView{
            id: swipe_view
            height: parent.height
            width: parent.width
            clip: true
    
            Item{
                id: home_screen
    
                Image {
                    id: wallpaper
                    anchors.fill: parent
                    source: "qrc:/images/arcs.png"
                    fillMode: Image.PreserveAspectFit
                }
    
                ColumnLayout{
                    id: content_layout
                    anchors.verticalCenter: parent.verticalCenter
                    anchors.left: parent.left
                    anchors.right: parent.right
                    spacing: 5
    
                    Text{
                        id: time
                        color: "#ffffff"
                        text: "16:00"
                        font.pointSize: 20
                        font.weight: Font.DemiBold
                        font.family: "Roboto"
                        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    }
    
                    Text{
                        id: day
                        color: "#ffffff"
    
                        font.weight: Font.ExtraLight
                        font.family: "Robot"
                        Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                    }
    
                    Timer{
                        interval: 500
                        running: true
                        repeat: true
    
                        onTriggered: {
                            var date = new Date()
                            time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm")
                            const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"]
                            let dayIndex = date.getDay()
                            day.text = days[dayIndex]
                        }
                    }
                }
            }
    
            Item{
    
            }
        }
    }
    
    

    Please help me out
    Thanks in advance

    sierdzioS JoeCFDJ 2 Replies Last reply
    0
    • R Raghav

      Hi,
      I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to load

      Here is my QML code:

      import QtQuick
      import QtQuick.Window
      import QtQuick.Layouts 1.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 240
          height: 240
          visible: true
          color: "transparent"
          maximumHeight: 240
          maximumWidth: 240
          minimumHeight: 240
          minimumWidth: 240
      
          Rectangle{
              id: circular_area
              height: parent.height
              width: parent.width
              radius: parent.width / 2
              color: "black"
          }
      
          SwipeView{
              id: swipe_view
              height: parent.height
              width: parent.width
              clip: true
      
              Item{
                  id: home_screen
      
                  Image {
                      id: wallpaper
                      anchors.fill: parent
                      source: "qrc:/images/arcs.png"
                      fillMode: Image.PreserveAspectFit
                  }
      
                  ColumnLayout{
                      id: content_layout
                      anchors.verticalCenter: parent.verticalCenter
                      anchors.left: parent.left
                      anchors.right: parent.right
                      spacing: 5
      
                      Text{
                          id: time
                          color: "#ffffff"
                          text: "16:00"
                          font.pointSize: 20
                          font.weight: Font.DemiBold
                          font.family: "Roboto"
                          Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                      }
      
                      Text{
                          id: day
                          color: "#ffffff"
      
                          font.weight: Font.ExtraLight
                          font.family: "Robot"
                          Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                      }
      
                      Timer{
                          interval: 500
                          running: true
                          repeat: true
      
                          onTriggered: {
                              var date = new Date()
                              time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm")
                              const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"]
                              let dayIndex = date.getDay()
                              day.text = days[dayIndex]
                          }
                      }
                  }
              }
      
              Item{
      
              }
          }
      }
      
      

      Please help me out
      Thanks in advance

      sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2
      Item{
        id: home_screen
      
        Image {
          id: wallpaper
          anchors.fill: parent
          source: "qrc:/images/arcs.png"
          fillMode: Image.PreserveAspectFit
        }
      

      Your home_screen item does not have dimensions (width and height) so in your Image the call to anchors.fill: parent does nothing. So your image is there but it spans 0x0 pixels.

      Plus, with QRC it's always tricky, so make sure the path is correct and also try other URLs like :/images/arcs.png or qrc://images/arcs.png.

      (Z(:^

      1 Reply Last reply
      0
      • R Raghav

        Hi,
        I am using Qt 6.5.0 and Qt Creator with Ubuntu. I am developing an interface for smart watch. So I was loading a background in it, but it seems not to load

        Here is my QML code:

        import QtQuick
        import QtQuick.Window
        import QtQuick.Layouts 1.15
        import QtQuick.Controls 2.15
        
        Window {
            width: 240
            height: 240
            visible: true
            color: "transparent"
            maximumHeight: 240
            maximumWidth: 240
            minimumHeight: 240
            minimumWidth: 240
        
            Rectangle{
                id: circular_area
                height: parent.height
                width: parent.width
                radius: parent.width / 2
                color: "black"
            }
        
            SwipeView{
                id: swipe_view
                height: parent.height
                width: parent.width
                clip: true
        
                Item{
                    id: home_screen
        
                    Image {
                        id: wallpaper
                        anchors.fill: parent
                        source: "qrc:/images/arcs.png"
                        fillMode: Image.PreserveAspectFit
                    }
        
                    ColumnLayout{
                        id: content_layout
                        anchors.verticalCenter: parent.verticalCenter
                        anchors.left: parent.left
                        anchors.right: parent.right
                        spacing: 5
        
                        Text{
                            id: time
                            color: "#ffffff"
                            text: "16:00"
                            font.pointSize: 20
                            font.weight: Font.DemiBold
                            font.family: "Roboto"
                            Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                        }
        
                        Text{
                            id: day
                            color: "#ffffff"
        
                            font.weight: Font.ExtraLight
                            font.family: "Robot"
                            Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
                        }
        
                        Timer{
                            interval: 500
                            running: true
                            repeat: true
        
                            onTriggered: {
                                var date = new Date()
                                time.text = date.toLocaleTimeString(Qt.locale("en_IN"), "hh:mm")
                                const days = ["Sunday", "Monday", "Tuesday", "Wednessday", "Thursday", "Friday", "Saturday"]
                                let dayIndex = date.getDay()
                                day.text = days[dayIndex]
                            }
                        }
                    }
                }
        
                Item{
        
                }
            }
        }
        
        

        Please help me out
        Thanks in advance

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @Raghav said in Image not loading:

        import QtQuick.Layouts 1.15
        import QtQuick.Controls 2.15

        import QtQuick.Layouts 1.15 <=version number is dropped in Qt6
        import QtQuick.Controls 2.15 <=version number is dropped in Qt6
        simply
        import QtQuick.Layouts 
        import QtQuick.Controls
        
        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved