Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Setting static path to image source
QtWS25 Last Chance

Setting static path to image source

Scheduled Pinned Locked Moved QML and Qt Quick
16 Posts 2 Posters 3.7k 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.
  • B Offline
    B Offline
    beemaneni
    wrote on last edited by
    #1

    hi friends

    I am trying to set static path to an image source which i was not able to overcome..I do not want an image to be used from qrc file...So i need to access an image from desktop in ubuntu qml qt..here i tried like

    Image {
    id: xxx
    anchors.centerIn: parent.center
    source: "file:///home/xx......../image1.jpg"
    or
    source: "/home/xx......../image1.jpg"
    }

    i could not load that image and i am trying hard to get..it will be greta if some one can help me with this..

    Thanks in Advance friends...

    Bala B
    Infinite Computer systems
    Chennai

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      I don't see any problem in source of Image element. Use "file:///" as prefix to path.
      Are you sure that the image path is correct ?
      Any error printed to the console ?

      157

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beemaneni
        wrote on last edited by
        #3

        Hi thanks for reply..

        I have used both methods..i did nt get any errors also..yeah i have given right path..

        Bala B
        Infinite Computer systems
        Chennai

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Can you post the complete code ? Please use Code tags "@@" while posting.

          157

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beemaneni
            wrote on last edited by
            #5

            Hi
            Here is the code posted ..sory i was not knowing how to use code tags

            @
            ListView {

                id : list
                anchors { left: parent.left; top: shutterButton.bottom; right: parent.right; bottom: parent.bottom}
                spacing: 3
                orientation: ListView.Horizontal
                model: 10              
                delegate: Rectangle {
                    anchors { verticalCenter: parent.verticalCenter }
                    width: 70; height: 70; color: "grey"; border.color: "#000"; radius: 5
                    Image {
                        id: imagecap
                        anchors { centerIn: parent }
                        visible: true
                        source: "file:///home/bala/Desktop/Image1.jpg"
                    }
                }
            }
            

            @

            Bala B
            Infinite Computer systems
            Chennai

            1 Reply Last reply
            0
            • p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              Alright Question, Is this the only code in your QML ? It seems you have not given width and height to ListView. Please try again with proper width and height for ListView.
              I'm assuming now that the file path is absolutly correct.

              157

              1 Reply Last reply
              0
              • B Offline
                B Offline
                beemaneni
                wrote on last edited by
                #7

                Hi,
                No this is nly part of the code...Actual thing is i am capturing an image from camera...where image is saved in sd card...so i have to give that path here...yeah i will try by giving width and height for list view and update u

                Bala B
                Infinite Computer systems
                Chennai

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  beemaneni
                  wrote on last edited by
                  #8

                  i tried with width and height for list view also but in no vain..did u get that working for u

                  Bala B
                  Infinite Computer systems
                  Chennai

                  1 Reply Last reply
                  0
                  • p3c0P Offline
                    p3c0P Offline
                    p3c0
                    Moderators
                    wrote on last edited by
                    #9

                    Well i tried this and it worked for me
                    @
                    ListView {
                    id : list
                    width: 200
                    height: 300
                    spacing: 3
                    model: 10
                    orientation: ListView.Horizontal
                    delegate: Rectangle {
                    anchors { verticalCenter: parent.verticalCenter }
                    width: 70; height: 70;
                    color: "grey";
                    border.color: "#000";
                    radius: 5
                    Image {
                    id: imagecap
                    anchors { centerIn: parent }
                    source: "file:///home/user1/Pictures/star.jpg"
                    }
                    }
                    }
                    @

                    157

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      beemaneni
                      wrote on last edited by
                      #10

                      hi thanks
                      i have not checked on desktop till now..it works gud for me on desktop..but it does not work on android mobile

                      Bala B
                      Infinite Computer systems
                      Chennai

                      1 Reply Last reply
                      0
                      • p3c0P Offline
                        p3c0P Offline
                        p3c0
                        Moderators
                        wrote on last edited by
                        #11

                        On Android it must be a different path.

                        157

                        1 Reply Last reply
                        0
                        • B Offline
                          B Offline
                          beemaneni
                          wrote on last edited by
                          #12

                          Hi
                          Actual code is i am capturing an image and saving that image in one path using "camera" class .I found where the image is saved using "camera.imageCapture.capturedimagepath()" ..path is like "/storage "/sdcard0/DCIM/******etc /img.png"..i assigned the path to listview image source. i deployed the application on android phone and found the path ,bt it is not retrieving in image source in listview...this is exactly my requirement..

                          Thanks for guiding...:-)

                          Bala B
                          Infinite Computer systems
                          Chennai

                          1 Reply Last reply
                          0
                          • p3c0P Offline
                            p3c0P Offline
                            p3c0
                            Moderators
                            wrote on last edited by
                            #13

                            And does it work if you assign some other already existing image ?
                            any errors in Qt Creator's console when you run the application on phone ?
                            Is the image that you captured a valid image ? you can try opening it in default image viewer on phone

                            157

                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              beemaneni
                              wrote on last edited by
                              #14

                              yeah i have included images through qrc file but nt static paths...in my phone it does not printt anything on console window...yeah image is an valid one and i am able to open and see in phone..

                              image saved in phone at: "/storage/sdcard0/DCIM/Pictures/IMG_00001.jpg"

                              the same path i have given as source to image as
                              "file:///storage/sdcard0/DCIM/Pictures/IMG_00001.jpg"

                              Bala B
                              Infinite Computer systems
                              Chennai

                              1 Reply Last reply
                              0
                              • B Offline
                                B Offline
                                beemaneni
                                wrote on last edited by
                                #15

                                hi

                                I found some bug in the aboe code i have given..
                                Inside the delegate->Rectangle image is placed...I could not access that image outside..How do i do that?

                                Bala B
                                Infinite Computer systems
                                Chennai

                                1 Reply Last reply
                                0
                                • p3c0P Offline
                                  p3c0P Offline
                                  p3c0
                                  Moderators
                                  wrote on last edited by
                                  #16

                                  Is the image accessible outside Rectangle ? You can try to use Image element directly instead of placing inside the Rectangle. But i don't think so that would be a problem.

                                  157

                                  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