Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Portuguese
  4. Array com todos os paths de um .qrc
Qt 6.11 is out! See what's new in the release blog

Array com todos os paths de um .qrc

Scheduled Pinned Locked Moved Portuguese
4 Posts 3 Posters 1.9k 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.
  • N Offline
    N Offline
    nt162
    wrote on last edited by
    #1

    Boas! Tudo bem? Primeiro post! ahaha

    Eu já ando nas andanças do Qt há algum tempo mas nunca usei muito os .qrc e esta é a primeira vez que encontro uma dificuldade sem resposta em lado nenhum!!

    Criei uma aplicação onde tenho um .qrc com várias imagens. O que eu pretendo é criar um array de um qualquer tipo com todos os paths presentes nesse .qrc.

    Existe alguma forma de eu fazer isto dinamicamente? Ou tenho mesmo que adicionar os paths um a um ao array?

    Abr.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TioRoy
      wrote on last edited by
      #2

      O .qrc para as classes do Qt age como um diretório comum.
      Logo, você pode usar, o QDir ou o QDirIterator:

      @
      QDir dir(":");
      QStringList list = dir.entryList();
      @

      Mas o entryList() não retorna os subdiretórios.
      Mas utilizando o QDirIterator:

      @
      QStringList listSubDir;
      QDirIterator dir_it(":", QDirIterator::Subdirectories);
      while (dir_it.hasNext()) {
      listSubDir << dir_it.next();
      }
      @

      Você tem a lista do qrc inteiro.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nt162
        wrote on last edited by
        #3

        Boa!!

        Não sabia nem tinha pensado no .qrc dessa forma!

        Muito obrigado!

        1 Reply Last reply
        0
        • P Offline
          P Offline
          patrik08
          wrote on last edited by
          #4

          também classificar por tipo... simplesmente...

          @
          /// found https://github.com/pehohlva/imq
          bool Compressor::appendDirname(const QString pwd) {
          QTextStream out(stdout);
          if (!invalidname(pwd)) {
          return false;
          }
          bool result = true;
          QDir dir(pwd);
          if (dir.exists(pwd)) {
          OsFile dirfromOS;
          dirfromOS.set_File(dir.absolutePath(), 3);
          if (writtel.device()) {
          writtel << dirfromOS;
          }
          out << "D:" << dir.absolutePath() << "\n";
          out.flush();

              Q_FOREACH(QFileInfo info, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
                  if (info.isDir()) {
                      result = appendDirname(info.absoluteFilePath());
                  } else if (info.isSymLink()) {
                      OsFile symslinkOS;
                      symslinkOS.set_File&#40;info.symLinkTarget(&#41;, 2);
                      symslinkOS.set_NameSimslink(info.fileName());
                      if (writtel.device()) {
                          writtel << symslinkOS;
                      }
          
                  } else if (info.isFile&#40;&#41;) {
                      result = appendFilename(info, info.absolutePath());
                  }
              }
          }
          
          return result;
          

          }

          @

          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