Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTWebEngine

QTWebEngine

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 2 Posters 585 Views 2 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.
  • C Offline
    C Offline
    continue98
    wrote on last edited by
    #1

    Hello. I have a question: where does qtwebengine try to take the about file from this code?

    void WebUiHandler::requestStarted(QWebEngineUrlRequestJob *job)
    {
        static const QUrl webUiOrigin(QStringLiteral(SCHEMENAME ":"));
        static const QByteArray GET(QByteArrayLiteral("GET"));
        static const QByteArray POST(QByteArrayLiteral("POST"));
    
        QByteArray method = job->requestMethod();
        QUrl url = job->requestUrl();
        QUrl initiator = job->initiator();
    
        if (method == GET && url == aboutUrl) {
            QFile *file = new QFile(QStringLiteral(":/about.html"), job);
            file->open(QIODevice::ReadOnly);
            job->reply(QByteArrayLiteral("text/html"), file);
        } else if (method == POST && url == aboutUrl && initiator == webUiOrigin) {
            job->fail(QWebEngineUrlRequestJob::RequestAborted);
            QApplication::exit();
        } else {
            job->fail(QWebEngineUrlRequestJob::UrlNotFound);
        }
    }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      From Qt's resource system.

      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
      • C Offline
        C Offline
        continue98
        wrote on last edited by
        #3

        @SGaist hmm, okey.

        void WebUiHandler::requestStarted(QWebEngineUrlRequestJob* job)
        {
            static const QUrl webUiOrigin(QStringLiteral(SCHEMENAME ":"));
            static const QByteArray GET(QByteArrayLiteral("GET"));
            static const QByteArray POST(QByteArrayLiteral("POST"));
            QByteArray method = job->requestMethod();
            QUrl url = job->requestUrl();
            QUrl initiator = job->initiator();
            if (method == GET && url == aboutUrl) {
                QFile* file = new QFile(QStringLiteral("frontend//index.html"), job);
                file->open(QIODevice::ReadOnly);
                job->reply(QByteArrayLiteral("text/html"), file);
            }
            else if (method == POST && url == aboutUrl && initiator == webUiOrigin) {
                job->fail(QWebEngineUrlRequestJob::RequestAborted);
                QApplication::exit();
            }
            else {
                job->fail(QWebEngineUrlRequestJob::UrlNotFound);
            }
        }
        

        I do so, but for some reason the css/styles are not loaded. do you know what could be the problem?

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

          No, I don't know:

          • what you are currently loading
          • where you are loading it from
          • the content of what you load
          • why do you do custom loading when the file:// scheme is likely already supported by webengine.

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

          C SGaistS 2 Replies Last reply
          0
          • SGaistS SGaist

            No, I don't know:

            • what you are currently loading
            • where you are loading it from
            • the content of what you load
            • why do you do custom loading when the file:// scheme is likely already supported by webengine.
            C Offline
            C Offline
            continue98
            wrote on last edited by continue98
            #5

            @SGaist said in QTWebEngine:

            No, I don't know:

            Failed to load resource: the server responded with a status of 404 (Not Found)
            46cb1a91ea5e4ff1.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            webpack-18dc8cac8996f2a2.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            framework-9b5d6ec4444c80fa.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            main-3123a443c688934f.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            _app-bef4f61ca1b225bc.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            333-7fb69cb7b7a584a1.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            index-9dd93c6d86de6970.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            _buildManifest.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            _ssgManifest.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            bg1.a92305e3.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            bg1.a92305e3.png:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
            ppapd.416e55e9.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            ppapd.416e55e9.png:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
            art1.393a9d9e.png:1 Failed to load resource: the server responded with a status of 404 (Not Found)
            art1.393a9d9e.png:1 Failed to load resource: net::ERR_FILE_NOT_FOUND
            

            in console. i run application with remote debugger

            strange, but I would like to solve it

            UPD: launcher:./_next/static/chunks/main-3123a443c688934f.js is strange path, because launcher://frontend/_next/.... - it try, but not launcher:./_next/static/chunks/main-3123a443c688934f.js

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

              Well, without answers to the points I raised in my previous answer, it will be hard to help.

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

              C 1 Reply Last reply
              0
              • SGaistS SGaist

                Well, without answers to the points I raised in my previous answer, it will be hard to help.

                C Offline
                C Offline
                continue98
                wrote on last edited by
                #7

                @SGaist said in QTWebEngine:

                Well, without answers to the points I raised in my previous answer, it will be hard to help.

                What would you like? will you run the frontend that I will give for you? Or what will answer these questions? I am running an application on nextjs.

                1 Reply Last reply
                0
                • SGaistS SGaist

                  No, I don't know:

                  • what you are currently loading
                  • where you are loading it from
                  • the content of what you load
                  • why do you do custom loading when the file:// scheme is likely already supported by webengine.
                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @SGaist said in QTWebEngine:

                  No, I don't know:

                  • what you are currently loading
                  • where you are loading it from
                  • the content of what you load
                  • why do you do custom loading when the file:// scheme is likely already supported by webengine.

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

                  C 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    @SGaist said in QTWebEngine:

                    No, I don't know:

                    • what you are currently loading
                    • where you are loading it from
                    • the content of what you load
                    • why do you do custom loading when the file:// scheme is likely already supported by webengine.
                    C Offline
                    C Offline
                    continue98
                    wrote on last edited by continue98
                    #9

                    @SGaist I am writing a desktop application (launcher). Interfaces are built on the web stack (js/css/html). Frontend write on nextjs. I use next export for generate static html. Next to the binary file (launcher.exe) there is a frontend folder, I put assets from nextjs there and try to run it, but the styles are not loaded. Custom schema is needed in order to load the frontend. file:// will not give you that option, you will have CORS. I attach an out folder (where nextjs generates a static page), but I don't understand why I'm doing this, because I don't think you will try to fix it and play with qtwebengine

                    P.S: I don't understand why you need this information?
                    P.S.S: You also can't run it in the browser because the browser can't run it, you need a http server thread to see what styles the page has
                    P.S.S.S: I know for sure that it can be run through a custom scheme and it will work. I had experience with CEF and it worked there.

                    In browser:

                    alt text

                    In qtwebengine:

                    alt text

                    SGaistS 1 Reply Last reply
                    0
                    • C continue98

                      @SGaist I am writing a desktop application (launcher). Interfaces are built on the web stack (js/css/html). Frontend write on nextjs. I use next export for generate static html. Next to the binary file (launcher.exe) there is a frontend folder, I put assets from nextjs there and try to run it, but the styles are not loaded. Custom schema is needed in order to load the frontend. file:// will not give you that option, you will have CORS. I attach an out folder (where nextjs generates a static page), but I don't understand why I'm doing this, because I don't think you will try to fix it and play with qtwebengine

                      P.S: I don't understand why you need this information?
                      P.S.S: You also can't run it in the browser because the browser can't run it, you need a http server thread to see what styles the page has
                      P.S.S.S: I know for sure that it can be run through a custom scheme and it will work. I had experience with CEF and it worked there.

                      In browser:

                      alt text

                      In qtwebengine:

                      alt text

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @continue98 said in QTWebEngine:

                      P.S: I don't understand why you need this information?

                      Because analizing a piece of code without any context makes it hard to provide any good information

                      P.S.S: You also can't run it in the browser because the browser can't run it, you need a http server thread to see what styles the page has

                      It depends on how it was designed, a web server is not mandatory because you are using html. Take for example the documentation generated by sphinx. You can go through it on your own machine with styling and all without the need for a web server.

                      P.S.S.S: I know for sure that it can be run through a custom scheme and it will work. I had experience with CEF and it worked there.

                      I never said it could not work with a custom scheme, I asked about them because you just posted code without context.

                      @continue98 said in QTWebEngine:

                      @SGaist I am writing a desktop application (launcher). Interfaces are built on the web stack (js/css/html). Frontend write on nextjs. I use next export for generate static html. Next to the binary file (launcher.exe) there is a frontend folder, I put assets from nextjs there and try to run it, but the styles are not loaded. Custom schema is needed in order to load the frontend. file:// will not give you that option, you will have CORS. I attach an out folder (where nextjs generates a static page), but I don't understand why I'm doing this, because I don't think you will try to fix it and play with qtwebengine

                      Taking that kind of position when someone requests information in order to be able to help you will not get you far.
                      Providing a minimal compilable project that reproduces your situation and thus allows other people to test will more likely.

                      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
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved