QtQt Charts 2.1.0 Release

Jan. 18, 2016, 12:37 a.m.

Charts, Qt, Qt Charts

Перевод официальной новости.

Мы счастливы объявить, что в предстоящий выпуск Qt 5.6.0 будет включён Qt Charts 2.1.0 add-on. Этот выпуск Qt содержит новый функционал, и исправлены баги по пользовательским запросам.

Краткое введение о том новом, что есть в этом модуле: Qt Charts является модулем, который предоставляет комплект простых в использовании компонентов графиков. Доступны следующие типы графиков: LLine, Spline, Area, Scatter, Bar, Pie, Polar and Box-and-Whiskers Chart.

QtQt WinAPI - Lesson 006. Parsing QKeySequence for RegisterHotKey in WinAPI

QKeySequence very different from the sequence of hotkeys in WinAPI . QKeySequence actually is a string in which the separator hotkeys are "+" sign, as well as the sequence ", " , if several sequences. Then, as in WinAPI there are modifiers Alt, Ctrl, Shift, which are represented by an unsigned integer type, and hot key, which is represented by the code keypad.

Let us research the option, when there is one sequence in QKeySequence and it is necessary to register as a global hotkey in WinAPI. To this end, we agree that QKeySequence as as a modifier will have only the Ctrl, Alt, Shift , and as hot keys one of the letters of the English alphabet.

Next to parse QKeySequence write two functions:

  • unsigned int winKeyMod(QKeySequence) - which will return an integer combination of modifiers;
  • char winHotKey(QKetSequence) -which will return the code of the hot key.

Modifiers Alt, Ctrl and Shift option in the bit values have 0b00000001 , 0b00000010 and 0b00000100 respectively, so the logical OR any number of data addition will give the required number of combinations. Hence it is necessary in the method winKeyMod , identify modifiers of the sequence and if any one of the modifier to be added that the method returns.

QMLQML - Lesson 022. Animation click on an item in the list Material Design style

Jan. 4, 2016, 10:41 a.m.

анимация, material design, Android, Qt, QML

QML does not provide animation interactions clicks Material Design Style for Android by default, but is easily adjusted with the Rectangle primitive. Animation is to one parent, Rectangle, when clicked, you need a second child Rectangle object to stretch the entire area of the parent. At the same time the child object will stretch for a certain time and will appear as an expanding circle, but it will not go beyond its parent.

For clarity, create a list of items, which will produce clicks. To track clicks is used area MouseArea, which will be monitored by the interaction of several signals:

  • onClicked - the signal will stop the animation and the result of the interaction performed with the list;
  • onPressed - when the signal is pressing need to run an animation preset coordinates animated object Rectangle.
  • onReleased - you need to stop the animation when you release the list item;
  • onPositionChanged - when you change the position of the field also need to stop the animation.

To make the animation used PropertyAnimation object. This site is chosen goal of animation, and a list of properties that will be subject to change. In the case of animatable object Rectangl, it is necessary to expand the circle, for that increase the properties width, height and radius with the same value. In order to completely fill the parent object properties will exhibit a finite amount three times greater than the width of the parent element.

Another important property is the parent element:

clip - activating this property (true), we cut the child elements of the object, so that they do not go beyond the boundaries of the parent element.

QtQt WinAPI - Lesson 005. Global HotKey WinAPI in Qt5

To work with global HotKey in Qt5 , there is a virtual method nativeEvent . This method replaces the methods winEvent , x11Event , macEvent of Qt 4.8 .

The especiality in the HotKey to Qt is that if the window is not in focus, that is, it is, for example, will be minimized to the system tray, then registered QShortcut simply will not work. It is therefore necessary to work with the global events from the operating system, that is, go to the realization of the platform-specific code in the application to Qt.

RegisterHotKey

In this example Let us examine the option of working with WinAPI. For this we use the function RegisterHotKey.

BOOL WINAPI RegisterHotKey(
  _In_opt_ HWND hWnd,
  _In_     int  id,
  _In_     UINT fsModifiers,
  _In_     UINT vk
);

QtQt WinAPI - Lesson 008. Adding Qt application into Windows autorun using QSettings

As is known, QSettings class allows you to store application settings in the registry of Windows . Due to this possibility, and a good knowledge of your Windows registry, you can add an application to autostart, or remove it from there, through, for example, the application settings dialog. You can use the checkbox, and if it is marked, then by clicking on the button in the confirmation dialog box to write an application to the startup, otherwise, remove it from the startup.

In any case, it all comes down to the two actions.

Write an application to autostart

#ifdef Q_OS_WIN32
    QSettings settings("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
    settings.setValue(APPLICATION_NAME, QDir::toNativeSeparators(QCoreApplication::applicationFilePath()));
    settings.sync();
#endif

QtQt/C++ - Lesson 041. JSON file – How to get from site and parsing it

In the process of writing programs EColor appeared a problem in which it was necessary in some way to notify the user that a new version of the program. The solution to this problem was the presence of JSON file on the site. With QNetworkAccessManager get a JSON file and produce his analysis, thanks to the class library Qt: QJsonDocument , QJsonObject , QJsonArray . In the case of the program on the website EColor contains JSON file with the name of the program, the full version in string form and three entities to the major part of the version, minor and patch version. When parsing the file is compared with the current version of the program that is on the website. If the site is lined with a newer version, the program will notify the user.

QtQt/C++ - Lesson 031. QCustomPlot – The build of charts with time

Dec. 27, 2015, 9:09 a.m.

QCustomPlot, QDateTime, Qt, время, график

QCustomPlot Library has the ability to charting the scale of time, which is useful in analyzing the data, which change over time. To do this, you need to install a signature style to the time axis as QCPAxis::ltDateTime. And then set the date and time format. That is, it is possible to display on the axes or the date or time, or simultaneously do both, depending on what you specify formatting. Formatting Rules for QCustomPlot used are the same as for QDateTime , QDate , QTime , classes.

Time coordinate is transmitted in the form of a double number that starts the countdown in seconds from time 1970-01-01T00:00:00 . What to consider when plotting.

I propose to write an application that will build a pseudo-random schedule of income and rubles according to the current time coordinate. At the same time the schedule will be to communicate, that is, zoom and remove it, and move, but only on the horizontal axis. That is, the height of the graph display will not change. Also, we make it possible to change the time format in the coordinate dependence of the visible area of ​​the chart for the time axis. That is, if the visible part of the graph in less than one day, the time-axis signature format will be as follows: hh: mm. Otherwise, the format is " dd MMM yy ".

Building a graph

We create a project and connect it to the library QCustomPlot . Modifications will be subject only mainwindow.h and mainwindow.cpp files. New files will not be added.

QMLQML - Lesson 021. Switching between windows in QML

Dec. 24, 2015, 10:27 a.m.

Qt, QML, window, Quick, Controls, QtQuick

One of the articles had a chance to answer the question the reader how to implement switching between windows in Q t, so that when you change an inactive window hidden. At the touch of a button opens a second window, and the first closing. And switch back the same way.

Now we ask the same question, but with regard to QML. So, let's see how to implement it on the QML.

Project structre

  • question4.pro - profile project, the default is created and does not change;
  • main.cpp - the main source file, the default is created and does not change;
  • main.qml - qml main file to the main application window;
  • AnotherWindow.qml - type secondary windows project.

AnotherWindow.qml

Explanation of code begin with a secondary application window, since the transmission of information on the button is pressed to open the main application window is realized by a signal. And it is more convenient to describe this moment in the beginning, before proceeding to the main application code.

QtQt/C++ - Lesson 037. The two-dimensional array using QVector

Class QVector relates to a container class, and provides access to the items on the index, as well as a number of additional methods for ease of operation.

QVector instance of the class is essentially a one-dimensional array of objects. If you want to set as a vector of two-dimensional array, you can create an instance of a QVector , which will contain other instances QVector .

One-Dimensional array using QVector

For starters keep in Vector-dimensional array of type int:

QVector <int> myVector;

int massive[4] = {1, 2, 3, 4};

for(int i = 0; i < 4; i++)
{
    myVector.push_back(massive[i]);
    qDebug() << "Value " << i << ": " << myVector.value(i);
}

And look at the output qDebug() :

Value  0 :  1
Value  1 :  2
Value  2 :  3
Value  3 :  4

QtQt/C++ - Lesson 032. Saving picture in file from QCustomPlot

Dec. 23, 2015, 9:36 a.m.

bmp, jpg, pdf, png, QCustomPlot, Qt, сохранение, файл

In a previous article on working with QCustomPlot was an example of the use of this library. But after the schedule is built, it may be necessary to make its preservation as a graphic file. QCustomPlot Library already provides methods necessary for this. All you need to do - is to create a file which will be saved and pass the path to the file in one of the methods to save the image.

Methods for saving images

saveRastered(const QString &fileName, int width, int height, double scale, const char *format, int quality)
saveJpg(const QString &fileName, int width, int height, double scale, int quality);
savePng(const QString &fileName, int width, int height, double scale, int quality);
saveBmp(const QString &fileName, int width, int height, double scale);
savePdf(const QString &fileName, bool noCosmeticPen, int width, int height, const QString &pdfCreator, const QString &pdfTitle);

saveRastered

It is a fundamental method for methods: saveJpg , savePng , saveBmp . So he called in all of these methods. Inside the method saveRastered QPixmap instance is created, through which the image is saved from QCustomPlot widget. For this method, you can specify the type of file to be saved. Then the remaining three methods simplify work and just write code, canceling the need to specify the file type.

savePdf

This method stands alone and does not use QPixmap , and runs through QPrinter . Although the use of logic in the minimum variant is similar to the rest of the methods.

How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it
Donate

Good day, Dear Users!!!

I am Evgenii Legotckoi, developer of EVILEG. And it is my hobby project, which helps to learn programming another programmers and developers

If the site helped you, and you want also support the development of the site, than you can donate by following ways

PayPalYandex.Money
Timeweb

Let me recommend you the excellent hosting on which EVILEG is located.

For many years, Timeweb has been proving his stability.

For projects on Django I recommend VDS hosting

View Hosting Timeweb
AS
May 26, 2020, 12:29 p.m.
Artem Sun-Dun-Chan

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
MN
May 25, 2020, 12:33 p.m.
Mitja Nagibin

C ++ - Test 004. Pointers, Arrays and Loops

  • Result:50points,
  • Rating points-4
f
May 25, 2020, 6:05 a.m.
falcon

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

  • Result:66points,
  • Rating points-1
Last comments
May 28, 2020, 4:14 p.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

Ну в моём примере, который в статье сработало так model->setData(model->index(1, 1), 7); Поскольку model->index(1, 0) - это индекс колонки id, которая скрыта, поэтому…
MA
May 28, 2020, 4:08 p.m.
Mihail A

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

Спасибо, завтра првоерю. А model->setData(model->index(1, 0), 7); Тоже заработало?
May 28, 2020, 4:06 p.m.
Evgenij Legotskoj

Qt/C++ - Lesson 039. How to paint stroke in QSqlTableModel by value in the column?

Да, метод data всё-таки влиял, я переписал его так и заработало удаление QVariant TableModel::data(const QModelIndex &idx, int role) const{ if (role == Qt::BackgroundColorRole) {…
May 28, 2020, 3:49 p.m.
Evgenij Legotskoj

Django - Tutorial 011. Adding comments to the site based on Django

Он более функциональный и его функционал объективно лучше поддерживается Django. Из первого, что приходит на ум: Это наличие полей типа Array Поддержка полей для JSON …
May 28, 2020, 3:42 p.m.
progammist

Django - Tutorial 011. Adding comments to the site based on Django

а в чем явное преимущество postgresql над mysql?)
Now discuss on the forum
RG
May 28, 2020, 7:21 p.m.
Rovshan Gurbanov

Сборка под старые версии Android

У меня SDK почти все версии есть, NDK есть версии 10, 17, 21. Но собирается приложение только с NDK v21 под Android версии 7.0 и выше Версия Qt у меня 5.14.2
May 28, 2020, 8:58 a.m.
Evgenij Legotskoj

Освобождение памяти QMainWindow::setCentralWidget

Да, соглашусь. Просто удаление происходит позже, а не сразу.
May 28, 2020, 6:43 a.m.
Mihailll

При подключении к git как указать пароль?

Нужно сделать ssh-keygen и потом полученый из файла код скопировать в ssh ключ в бикбакете
F
May 28, 2020, 2:42 a.m.
Fidan

QML

Да, проблема ушла, спасибо.
May 1, 2020, 9:19 a.m.
Mihailll

Как в Qt в qmenu добавить scrollarea

Вот это наследованный класс меню. Но посути это обычное меню. #pragma once#include <QtWidgets>class TransMenu : public QMenu { Q_OBJECTpublic: TransMenu(QWidget* parent = …
About
Services
© EVILEG 2015-2020
Recommend hosting TIMEWEB