QTWebEngine
-
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); } }
-
Hi,
From Qt's resource system.
-
@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?
-
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.
-
@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
-
Well, without answers to the points I raised in my previous answer, it will be hard to help.
-
@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.
-
@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.
-
@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:
In qtwebengine:
-
@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.