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

Qt

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

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

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:

http://www.example.com/?page=24&info=13

The parameters in this case are page and info .

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

QML

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.

Django

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.
Ambient

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

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

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

.pragma library
function login(username, password) {        
        var params = 'username=' + encodeURIComponent(username) +
        '&password=' + encodeURIComponent(password);
        var request = new XMLHttpRequest()
        request.open('POST', 'http://auth-test.app-labs.ru/api/login')
        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')
        request.send(params)    
}

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

QML

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:

  • TargetGame.pro - 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.

Nov. 16, 2018, 7:09 p.m.
Илья Завьялов

Qt - Test 001. Signals and slots

  • Result:31points,
  • Rating scores-10
Nov. 16, 2018, 12:49 p.m.
Ирина Минигузина

C++ - Тест 003. Условия и циклы

  • Result:0points,
  • Rating scores-10
Nov. 16, 2018, 8:55 a.m.
Vitaliy

Qt - Test 001. Signals and slots

  • Result:52points,
  • Rating scores-4
Recent comments
Nov. 16, 2018, 6:50 a.m.
Евгений Легоцкой

Добрый день! шаблон не находит, или шаблон неправильно прописали, или тег шаблона неправильно написан, иных выводов сделать не могу, из того, что вы написали. трейсбек нужно смотреть. Со...
Nov. 16, 2018, 6:48 a.m.
Евгений Легоцкой

пройтись циклом по всем виджетам в обратном порядке for (int i = ui->vertialLayout->count() - 1; i >= 0; --i){ QWidget* w = ui->verticalLyout->itemAt(i)->widget();...
Nov. 15, 2018, 9:35 p.m.
chunk

Доброго времени суток Евгений. Не подскажете что я делаю не так? Получаю ошибку такого характера: Reverse for 'add_comment' with arguments '('',)' not found. 1 pattern(s) tried: ...
Nov. 15, 2018, 3:35 p.m.
Михаиллл

Спасибо. Похоже где то описку сделал, поэтому не работало. Я добавил на verticalLayout много виджитов. А можно ли их как то быстро и просто удалить?
Nov. 15, 2018, 2:55 p.m.
Евгений Легоцкой

verticalLayout - это, по-моему предположению, должен быть у вас объект класса QVBoxLayout, который наследован от QBoxLayout. Поэтому открываете документацию на QVBoxLayout ...
Now discuss on the forum
Nov. 17, 2018, 11:20 p.m.
Евгений Легоцкой

Три года назад я подключал ffmpeg в проект на Qt/С++ на первой работе. И кодирование декодирование удалось запустить. Подключал как библиотеку. Думаю, что в зависимости от проекта мо...
Nov. 17, 2018, 2:13 p.m.
Чарльз Грин

Я сейчас занимаюсь мультимедией, это аудио и видео, программы для концертов и т. д. Бибилиотека Qt очень помогает, она надежная, а надежность в моих приложениях очень важный фактор чтоб не пол...
Nov. 16, 2018, 4:28 p.m.
Евгений Легоцкой

Добрый день! Спасибо, что воспользовались именно форумом. Заниматься курсовыми работами чьими-то ни было у меня времени нет, у самого полторы работы. Но что-то подсказать на фо...
Nov. 16, 2018, 9:52 a.m.
Евгений Легоцкой

Отладчик!!!! Версия комплекта MSVC 2015 + компилятор 14.0!!!!
Join us in social networks

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