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. QML and Qt compile problem
Qt 6.11 is out! See what's new in the release blog

QML and Qt compile problem

Scheduled Pinned Locked Moved QML and Qt Quick
9 Posts 3 Posters 10.1k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    How to allows QML resource files to be stored as binary files in an application executable .My application executable is anpicture_viewer of mixed QML/c++ .I have made a resource file ,the errror is cann't fonud displaied pictures.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      leon.anavi
      wrote on last edited by
      #2

      Please share more information about the errors by showing the build issues and the compile output.

      http://anavi.org/

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Resource files are the way to go. If you have issues with files that are not found, you are not setting your paths correctly.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          my error is qrc:/qml/qmlevolution/PicturePathviewDelegate.qml:19:9: QML Image: Cannot open: qrc:/home/user/MyDocs/DCIM/png/320_50633_fe167344f5c3eb3.png

          my picture path is /home/user/MyDocs/DCIM/png

          the picture displaied normal when there is no resource file

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            You mean that inside your resource file, you use the /home/user/MyDocs/DCIM/png/ path?! That path looks suspiciously like a local file path.

            Personally, I'd just use something like images/ as the path in my qrc.

            Could you show us the contents of your .qrc file please?

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              my icon of png can display but the picture_viewer application executable can't display nesssary pictures in /home/user/MyDocs/DICM/png

              @
              <RCC>
              <qresource prefix="/">
              <file>qml/qmlevolution/main.qml</file>
              <file>qml/qmlevolution/1.png</file>
              <file>qml/qmlevolution/2.png</file>
              <file>qml/qmlevolution/add.png</file>
              <file>qml/qmlevolution/album.png</file>
              <file>qml/qmlevolution/back.png</file>
              <file>qml/qmlevolution/delete.png</file>
              <file>qml/qmlevolution/plus.png</file>
              <file>qml/qmlevolution/Qt.png</file>
              <file>qml/qmlevolution/rotation.png</file>
              <file>qml/qmlevolution/slide.png</file>
              <file>qml/qmlevolution/zoomIn.png</file>
              <file>qml/qmlevolution/zoomOut.png</file>
              <file>qml/qmlevolution/AlbumName.qml</file>
              <file>qml/qmlevolution/DisplayAlbumDescription.qml</file>
              <file>qml/qmlevolution/DisplayAlbumNameDelegate.qml</file>
              <file>qml/qmlevolution/DisplayAlbumNameMenu.qml</file>
              <file>qml/qmlevolution/HoldMenu.qml</file>
              <file>qml/qmlevolution/NewAlbumDialog.qml</file>
              <file>qml/qmlevolution/NQEButton.qml</file>
              <file>qml/qmlevolution/PictureGridView.qml</file>
              <file>qml/qmlevolution/PictureGridViewDelegate.qml</file>
              <file>qml/qmlevolution/PictureListView.qml</file>
              <file>qml/qmlevolution/PictureListViewDelegate.qml</file>
              <file>qml/qmlevolution/PicturePathView.qml</file>
              <file>qml/qmlevolution/PicturePathviewDelegate.qml</file>
              <file>qml/qmlevolution/SplashScreen.qml</file>
              <file>qml/qmlevolution/ToolBar.qml</file>
              <file>componentCreation.js</file>
              </qresource>
              </RCC>
              @

              [[marked up code, Tobias]]

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                The problem is quite obvious then, I think:

                You are trying to load an image file with the :/home/user/MyDocs/DCIM/png/320_50633_fe167344f5c3eb3.png path, but that path does not exist in your resource.

                You should use relative paths in your qml files. That prevents issues like these. On top of that, I would suggest you group your files properly. That is: you put images in a separate directory. That is just a style issue though.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  I don.t want :/home/user/MyDocs/DCIM/png/320_50633_fe167344f5c3eb3.png as icon
                  Though I don't add the directory in resource file ,the error is the directory automaticly added qrc
                  I use QDir to load and scan /home/user/MyDocs/DCIM/png/
                  the code as fellow

                  @
                  m_pictureFolder = new PictureFolder("/home/user/MyDocs/DCIM/png");

                  PictureFolder::PictureFolder(const QString workDir)
                  {
                  m_qListPicture = new QList<Picture>;
                  QStringList filters;
                  foreach(QByteArray format, QImageReader::supportedImageFormats())
                  filters += "." + format;
                  imageScan(workDir,filters/
                  ,out*/);
                  }

                  void PictureFolder::imageScan(const QString &path,const QStringList &filters/, QTextStream &out/)
                  {
                  QDir pictureDir(path);

                  foreach(QString file, pictureDir.entryList(filters,QDir::Files))
                  {
                      file=pictureDir.absoluteFilePath(file);
                      *m_qListPicture << Picture(file,"comments here:");/*生成了一个图片对象*/
                  
                  }
                  
                  foreach(QString subDir, pictureDir.entryList(QDir::Dirs|QDir::NoDotAndDotDot))
                      imageScan(path + QDir::separator() + subDir, filters/*,out*/);
                  

                  }
                  @

                  Edit: please use @ tags around code sections for proper highlighting; Andre

                  1 Reply Last reply
                  0
                  • ? Offline
                    ? Offline
                    A Former User
                    wrote on last edited by
                    #9

                    I hava find the problem Thanks because I didn't add 'file://' ahead picture path
                    it is an protocol of QUrl

                    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