alex_lipAug. 16, 2018, 4:48 a.m.
Serving UI via HTTP
Продолжаю разбирать примеры - вот пример
===================================================
Serving UI via HTTP
To load a simple user interface via HTTP we need to have a web-server, which serves the UI documents. We start
of with our own simple web-server using a python one-liner. But first we need to have our demo user interface.
For this we create a small main.qml file in our project folder and create a red rectangle inside.
// main.qml
import QtQuick 2.5
Rectangle {
width: 320
height: 320
color: '#ff0000'
}
To serve this file we launch a small python script:
$ cd <PROJECT>
# python -m SimpleHTTPServer 8080
Now our file should be reachable via http://localhost:8080/main.qml. You can test it with:
$ curl http://localhost:8080/main.qml
Or just point your browser to the location. Your browser does not understand QML and will not be able to render
the document through. We need to create now such a browser for QML documents. To render the document we
need to point our qmlscene to the location. Unfortunately the qmlscene is limited to local files only. We
could overcome this limitation by writing our own qmlscene replacement or simple dynamically load it using
QML. We choose the dynamic loading as it works just fine. For this we use a loader element to retrieve for us the
remote document.
// remote.qml
import QtQuick 2.5
Loader {
id: root
source: 'http://localhost:8080/main2.qml'
onLoaded: {
root.width = item.width
root.height = item.height
}
}
Now we can ask the qmlscene to load the local remote.qml loader document. There is one glitch still. The
loader will resize to the size of the loaded item. And our qmlscene needs also to adapt to that size. This can be
accomplished using the --resize-to-root option to the qmlscene:
$ qmlscene --resize-to-root remote.qml
Resize to root tells the qml scene to resize its window to the size of the root element. The remote is now loading
the main.qml from our local server and resizes itself to the loaded user interface. Sweet and simple.
To load a simple user interface via HTTP we need to have a web-server, which serves the UI documents. We start
of with our own simple web-server using a python one-liner. But first we need to have our demo user interface.
For this we create a small main.qml file in our project folder and create a red rectangle inside.
// main.qml
import QtQuick 2.5
Rectangle {
width: 320
height: 320
color: '#ff0000'
}
To serve this file we launch a small python script:
$ cd <PROJECT>
# python -m SimpleHTTPServer 8080
Now our file should be reachable via http://localhost:8080/main.qml. You can test it with:
$ curl http://localhost:8080/main.qml
Or just point your browser to the location. Your browser does not understand QML and will not be able to render
the document through. We need to create now such a browser for QML documents. To render the document we
need to point our qmlscene to the location. Unfortunately the qmlscene is limited to local files only. We
could overcome this limitation by writing our own qmlscene replacement or simple dynamically load it using
QML. We choose the dynamic loading as it works just fine. For this we use a loader element to retrieve for us the
remote document.
// remote.qml
import QtQuick 2.5
Loader {
id: root
source: 'http://localhost:8080/main2.qml'
onLoaded: {
root.width = item.width
root.height = item.height
}
}
Now we can ask the qmlscene to load the local remote.qml loader document. There is one glitch still. The
loader will resize to the size of the loaded item. And our qmlscene needs also to adapt to that size. This can be
accomplished using the --resize-to-root option to the qmlscene:
$ qmlscene --resize-to-root remote.qml
Resize to root tells the qml scene to resize its window to the size of the root element. The remote is now loading
the main.qml from our local server and resizes itself to the loaded user interface. Sweet and simple.
====================================================================================
Питон у меня установлен - но как запустить локальный SimpleHTTPServer - я не понимаю -
когда я пишу в командной строке
C:\qt_buy> python -m SimpleHTTPServer 8080
- ругается -
C:\Python35\python.exe: No module named SimpleHTTPServer
We recommend hosting TIMEWEB
Stable hosting, on which the social network EVILEG is located. For projects on Django we recommend VDS hosting.Do you like it? Share on social networks!
AD
- Akiv Doros
- Nov. 11, 2024, 10:58 p.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:50points,
- Rating points-4
m
- molni99
- Oct. 26, 2024, 8:37 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:80points,
- Rating points4
m
- molni99
- Oct. 26, 2024, 8:29 a.m.
C ++ - Test 004. Pointers, Arrays and Loops
- Result:20points,
- Rating points-10
Last comments
Qt/C++ - Lesson 031. QCustomPlot – The build of charts with time buy generic priligy We can just chat, and we will not lose too much time anyway
Qt/C++ - Lesson 060. Configuring the appearance of the application in runtime I didnt have an issue work colors priligy dapoxetine 60mg revia cost uk August 3, 2022 Reply
Circuit switching and packet data transmission networks Angioedema 1 priligy dapoxetine
How to Copy Files in Linux If only females relatives with DZ offspring were considered these percentages were 23 order priligy online uk
Qt/C++ - Tutorial 068. Hello World using the CMAKE build system in CLion ditropan pristiq dosing With the Yankees leading, 4 3, Rivera jogged in from the bullpen to a standing ovation as he prepared for his final appearance in Chicago buy priligy pakistan
Now discuss on the forum
добавить qlineseries в функции priligy amazon canada 93 GREB1 protein GREB1 AB011147 6
Всё ещё разбираюсь с кешем. priligy walgreens levitra dulcolax carbs The third ring was found to be made up of ultra relativistic electrons, which are also present in both the outer and inner rings
IscanderCheOct. 31, 2024, 10:43 p.m.
Машина тьюринга // Начальное состояние 0 0, ,<,1 // Переход в состояние 1 при пустом символе 0,0,>,0 // Остаемся в состоянии 0, двигаясь вправо при встрече 0 0,1,>…
ИМ
Реализация навигации по разделам Спасибо Евгений!
Игорь МаксимовOct. 3, 2024, 11:05 a.m.
Добрый день!