Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. Resource, QResource and filesize
Forum Updated to NodeBB v4.3 + New Features

Resource, QResource and filesize

Scheduled Pinned Locked Moved C++ Gurus
5 Posts 2 Posters 1.6k 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.
  • T Offline
    T Offline
    TheIntruder
    wrote on last edited by
    #1

    I need to compile a javascript file into a Qt c++ application. Preferebly I would loved to include that file via some c++ code. I did not fine a solution. Now I am utilizing QResource via .qrc. But that method show the awkward sideeffect of not reading files with more than 40 lines aka some kB.

    How can I solve that problem. The javascript file may contain thousands of lines and I do not want to make a song and dance every time I want to compile and use that file in my c++ application!

    And I am still open to the non qt solution of my tragic dilemma:)

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      qrc should support files bigger than what you currently have. What errors are you getting ? Can you show the code where you access your javascript file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheIntruder
        wrote on last edited by
        #3

        Well.. I am not getting any error. The data is just not there, as if a buffer is not filled due to some buffer overflow. One by one I reduced the number of lines from the javascript file and once the number of lines has been minimized enough, the text of javascript is shown.
        @
        if(!CLASSNAME || std::find(this->classNameList.begin(), this->classNameList.end(), (char*)CLASSNAME) != this->classNameList.end())
        {
        return;
        }

        this->classNameList.push_back((char*)CLASSNAME);
        
        QResource jsResource(CLASSNAME);
        if(!jsResource.data())
        {
            return;
        }
        std::cout << "Filesize " << jsResource.size() << std::endl;
        

        @

        Mit CLASSNAME definiert durch

        @
        char* command = (char*)malloc(strlen(Widget::Widget_JsInterface::FRONTEND_CLIENT) + strlen(OsWrapper::correctClassName(typeid(*this).name())));
        ::sprintf(command, Widget::Widget_JsInterface::FRONTEND_CLIENT, OsWrapper::correctClassName(typeid(*this).name()));
        Widget::addJsElements(command);
        delete command;
        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Why not just use QFile to read your javascript file ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • T Offline
            T Offline
            TheIntruder
            wrote on last edited by
            #5

            I just found out about that solution! It was a little tough to be found and I never would have guessed it. But thanks.

            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