Privacy policyContactsAbout siteOpinionsGitHubDonate
© EVILEG 2015-2018
Recommend hosting
Oct. 11, 2018, 6:04 p.m.


Qt, QScriptEngine, QScriptValue, JavaScript, QScriptContext

Suppose you are faced with the task of executing JavaScript code in a C++ application. For example, there is a set of output data or variables whose names are known in advance, and there are pieces of JavaScript code that does something with these variables. And there is also an algorithm that, if there are any conditions, it will choose. which javascript code should be run.

Also, you can't just take and rewrite that JavaScript code into C++ code and hardcorely add it to the application. Since there are a lot of such pieces of code, at the same time other people are engaged in their maintenance and constantly add new pieces of code.

That is, in this case, the set of input data and JavaScript code for us is data, in some way the content that we launch using a certain algorithm, according to which we choose, under what conditions to choose one or another for the same set of input variables a piece of javascript code.

I hope that I clearly explained why we need to run the execution of JavaScript code in a C++ application.

I suggest to write an application that has two input fields for variable names, two input fields with input for the values of these variables in double format, in case of entering a value other than double data type, we will set the value to Undefined .

We will also add an TextEdit input field for writing JavaScript code that we will execute in our application.

And the last input field will be called Result (this will be TextEdit ), which will be responsible for the output of the new calculated values of the variables we entered.

Also add a QPushButton, which will run the execution of JavaScript code.

The application will look like the image below.

Jan. 8, 2018, 7:52 a.m.


Django, URL, JavaScript

The less information a site has to transmit to each request, the better. Because we get less load on the server and on the communication channel. The first such improvement on the site I did was loading the list of articles when navigating the page paginator.

The point is that when the user wants to go to the next page with a list of articles and clicks on the link in the paginator , the click event is intercepted, the event is canceled, but the AJAX request is sent to the server with the number of the requested page. When the server receives such a request, it only renders the list of articles and sends it back.

Jan. 7, 2018, 7:52 p.m.


JavaScript, URL

During the development of the site, small tasks arise, for example, how to extract a parameter from the URL.

For example, we have a URL like this:

The parameters in this case are page and info .

Nov. 6, 2017, 11:05 a.m.


QML, JavaScript, import

In the framework of the project on QML there is an opportunity not only to connect JavaScript files in QML files, but also in other JavaScript files. The syntax for connecting these files will be similar to that used in QML files.

For example, a variant of connecting a JavaScript file in a QML file

import "first.js" as FirstJs

Then, how to connect a JavaScript file to another JavaScript file will differ only by the presence of a dot before this line

.import "first.js" as FirstJs
Sept. 17, 2017, 8:10 a.m.


Minification, CSS, JavaScript

When developing a website, it is often noticed that the site should have a short response time to the user's actions, so they apply various methods to improve the site's performance, such as caching data on the user side, using cookies, as well as minimizing CSS and JavaScript files. Minimizing the code of these files allows you to remove unnecessary spaces, symbols and comments that are not needed on the production server, but are only required for project development.

Traditionally, an additional file extension min is added to the original file extension, which means a minified file.

  • style.css -> style.min.css
  • scripts.js -> scripts.miin.js

I propose to set up the PyCharm development environment to automatically minify all these files in your Django project.

Minimizing the css and jsavascript code is only supported in PyCharm Professional Edition.

An important point, the configuration will be done under the Ubuntu-based operating system KDE Neon 5.8. Installing the necessary packages for Windows, I do not consider, because I believe that the development of Django project under this OS is a mauveton.

April 12, 2017, 4:03 a.m.

Всем привет!!
Разираюсь с nginx и включил кеширование статичных файлов, ну там скриптов, CSS, картинок и т.д на стороне пользовательского браузера. Так вот, когда я меняю что-то в CSS или javascript, то изменения не применяются пока не нажать последовательно CTRL+R CTRL+F5. Только тогда браузер скачивает новые скрипты и стили. Ладно я могу так сделать пока тестирую и разрабатываю сайт, но пользователь же так не будет делать, да и возможно не знает о таком. Как можно заставить пользовательский браузер обновить эти файлы, когда включено кеширование?

Feb. 6, 2017, 8:06 p.m.

У меня есть JS файл, в котором я отправляю запросы, как мне в этой же функции управлять QML компонентами в main.qml или другом QML файле.

.pragma library
function login(username, password) {        
        var params = 'username=' + encodeURIComponent(username) +
        '&password=' + encodeURIComponent(password);
        var request = new XMLHttpRequest()'POST', '')
        request.onreadystatechange = function() {
            if (request.readyState === XMLHttpRequest.DONE) {
                console.log("Status", request.status)
                if (request.status && request.status === 200) {
                    console.log("response", request.responseText)                    
                } else {
                    console.log("HTTP:", request.status, request.statusText)
        request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

July 14, 2016, 9:57 a.m.


JavaScript, QML, Qt, динамические объекты, игровая арена

After the first experience of writing games on Qt for Android, I want to share this experience together and offer to write a simple game in the style of "kill the mole." This is a game in which you need to have time to hit the moles, which climbs out of their holes, but considering that this is a simplified game, instead of moles using the circular target, which will appear on the playing field. As the playing field will use the net 6 6 cells. But to create a field will not be used to some special object of type GridLayout . In the game board will be formed of a grid of rows, columns and the side length of a square cell. Data on occupancy cells to be stored in a two-dimensional array, which will be formed in javascript component (to forget that QML - a declarative JSON-like language with javascript enabled).

Project structure

The project consists of the following files:

  • - the profile of the project;
  • deployment.pri - build file and project deploya;
  • main.cpp - the file with the main function of the project;
  • main.qml - basic QML-layer file with the object of the main application window;
  • Target.qml - QML file with the description of the target object;
  • Target.png - the appearance of the target pattern is png;
  • GameArea.qml - gaming arena with the grid to accommodate the targets;
  • logic.js - file with javascript logic games.

We will study the contents of only those files that are different from the default content when creating the project.

March 23, 2019, 7:52 a.m.

C++ - Test 001. The first program and data types

  • Result:80points,
  • Rating points4
March 22, 2019, 9:39 a.m.

Qt - Test 001. Signals and slots

  • Result:21points,
  • Rating points-10
Last comments
March 22, 2019, 12:32 p.m.
Евгений Легоцкой

Ну может бибилотеки не те положили? У вас сборка для MinGW, а либы для MSVC.
March 22, 2019, 11:08 a.m.
Волчонок Над-Пропастью

Из кьюта приложение не хочет запускаться, аварийно завершается, но каких-либо ошибок не выдаёт. Оно открывается, после нажатия "старт" зависает и завершается. Если не из кьюта запускать дебаг ...
March 21, 2019, 3:49 p.m.
Евгений Легоцкой

серьезно? Эта ошибка 404 уже даже не относится к данному вопросу. В каких-то urls в вашем проекте. Вопросы, которые не относятся непосредственно к статье, задавайте, пожалуйста на...
March 21, 2019, 3 p.m.
Артем Бел

а это где? сейчас ошибка в debag такая: Page not found (404)Request Method: GETRequest URL:
March 21, 2019, 12:47 p.m.
Евгений Легоцкой

не вижу здесь проблемы, поменяйте url для callback в приложения oauth в социальных сетях
Now discuss on the forum
March 22, 2019, 7:40 p.m.

int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow w;; if (argc==2) { w.openFile(argv[1]); } return a.exec();} Допустим...
March 22, 2019, 12:29 p.m.

Да, мьютекс добавил, но в том потоке, где сигнал вызывается.
March 22, 2019, 9:04 a.m.
Волчонок Над-Пропастью

Да, на эту проблему! Зато у меня теперь новая, ругается на подключение QMediaPlayer, пишет, что не находит подобного файла или библиотеки. Пока не нашла как исправить, только вариант с переуст...
March 22, 2019, 8:58 a.m.

4) это , похоже, для создания видоизмененных страниц, для анимации. 3,5) добавить фвйл/qt/ui.qml
March 22, 2019, 8:04 a.m.
Евгений Легоцкой

Привет. Если там std::vector , то наверное можно заранее подготовить вектор с необходимым количеством элементов и просто устанавливать значение по индексу элемента. Но в данном слу...
Join us in social networks

For registered users on the site there is a minimum amount of advertising