Resource, QResource and filesize



  • 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:)


  • Lifetime Qt Champion

    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 ?



  • 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;
    @


  • Lifetime Qt Champion

    Why not just use QFile to read your javascript file ?



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.