Evgenij LegotskojOct. 19, 2015, 1:23 p.m.

QtGameDev on Qt - Tutorial 5. The explosion of bullets using sprite images

GameDev, Bullet, QPixmap, Qt, sprite, sprite sheet, explosion. взрыв, Спрайт

In previous articles we have learned to draw a sprite image and apply it to Qt via QPixmap so we turned animated explosion. And now we need to put this very explosion at precisely the place where the bullet hits. That is, the bullet will explode.

For the implementation of this ideas will add class sprite from the past lessons, and modify it. The fact is that the sprite object is a class inherited from QGraphicsItem , and therefore a bullet when confronted with the explosion of another bullet will behave as well as in a collision with an obstacle or a target. Therefore it is necessary to do so to ignore the bullets from the other explosions and bullets flying through.

Project structure

The project is subject to modification in the sense that a new class is added to the following files:

  • sprite.h
  • sprite.cpp

This class will be called animated sprite explosion, after which this frame object will be removed from the graphic scene.

Evgenij LegotskojOct. 18, 2015, 8:54 a.m.

QtQt/C++ - Lesson 028. How to use sprite picture with QPixmap?

QPixmap, Qt sprite, Qt, sprite, sprite QPixmap

Once we have drawn sprite last lesson on working with Adobe Illustrator , it's time to apply the resulting image when working with Qt and add it to the program using QPixmap . Moreover, we do Animated sprite, and see how the small explosion Animated graphics on the stage of our application on Qt.

The project structure to work with QPixmap and sprite

sprite_example project structure will be as follows:

  • sprite_example.pro - the profile of the project;
  • widget.h - header file of the main application window;
  • widget.cpp - file source code of the main application window;
  • widget.ui - interface file;
  • sprite.h - class header file that is used for our sprite, which will be applied QPixmap;
  • sprite.cpp - file source code to work with QPixmap;
  • sprite.qrc - resource file;
  • sprite_sheet.png - our sprite, which we will use for the animation.
Evgenij LegotskojOct. 17, 2015, 6:42 a.m.

Graphics and DesignHow to draw a sprite sheet in the Adobe Illustrator

adobe, adobe illustrator, sprite sheet, sprite, спрайт

Мне надоело тестировать процессы GameDev с помощью треугольников и прямоугольников. Это скучно и не интересно, поэтому настало время что-нибудь взорвать. Но с чего начать? - спросите Вы. А я отвечу, нужно нарисовать sprite взрыва, если быть точным, то нарисовать sprite sheet для взрыва, который будет представлять анимацию взрыва.

Но как это сделать? - этим вопросом озадачился я. После изучения нескольких форумов и видеоуроков, я решил собрать полученную информацию в один урок на своём сайте. Итак у нас следующее технической задание на этот урок:

  1. Нарисовать несколько sprite картинок, из которых мы сделаем sprite sheet для анимации взрыва;
  2. Собрать сам sprite sheet и сохранить его в PNG файл;
  3. Сделать всё это, используя ПО Adove Illustrator .
Evgenij LegotskojOct. 16, 2015, 12:25 p.m.

QtQt/C++ - Lesson 025. Creating Project Files

sources, headers, qt, config, libs, qt5, qmake

Project files contain all the information required by qmake to build your application, library, or plugin. Generally, you use a series of declarations to specify the resources in the project, but support for simple programming constructs enables you to describe different build processes for different platforms and environments.

Project File Elements

The project file format used by qmake can be used to support both simple and fairly complex build systems. Simple project files use a straightforward declarative style, defining standard variables to indicate the source and header files that are used in the project. Complex projects may use control flow structures to fine-tune the build process.

Variables

In a project file, variables are used to hold lists of strings. In the simplest projects, these variables inform qmake about the configuration options to use, or supply filenames and paths to use in the build process.

qmake looks for certain variables in each project file, and it uses the contents of these to determine what it should write to a Makefile. For example, the lists of values in the HEADERS and SOURCES variables are used to tell qmake about header and source files in the same directory as the project file.

Variables can also be used internally to store temporary lists of values, and existing lists of values can be overwritten or extended with new values.

The following snippet illustrates how lists of values are assigned to variables:

HEADERS = mainwindow.h paintwidget.h

The list of values in a variable is extended in the following way:

SOURCES = main.cpp mainwindow.cpp \
          paintwidget.cpp
CONFIG += console

Note: The first assignment only includes values that are specified on the same line as the HEADERS variable. The second assignment splits the values in the SOURCES variable across lines by using a backslash (\).

The CONFIG variable is another special variable that qmake uses when generating a Makefile.

Evgenij LegotskojOct. 15, 2015, 12:05 p.m.

QMLQML - Lesson 004. Signals and Slots in Qt QML

connections, example, qml, qml урок, qt, qt qml, qt урок, signal qml, slot qml, сигналы и слоты qml

And we got to transfer data between a layer of QML and C ++ layer. Frankly speaking, the principle is as simple as just using signals and slots in a single layer C ++. Especially in Qt 5.5.

An example will be shown on the basis of the code from the previous tutorial , where we have created a dialog box. But screenshots example works on Android will not be shown, but I assure you - Everything works like a Swiss watch.

Project Structure

Compared to the previous lesson, we had some changes. Namely, it adds a new class, which will be the core of the application.

  • appcore.h - application core file header;
  • appcore.cpp - application core source file.

And we continue to work and be with QQMLApplicationEngine. You will need to just take from the engine QML context and download it to a new class of object from which the signals in which data will be transmitted will be received.

Evgenij LegotskojOct. 13, 2015, 11:37 a.m.

QMLQML - Lesson 003. Custom Dialog in QML Android

custom dialog, dialog android, qml custom dialog, qml custom dialog example, qml dialog android, qt, qt android, qt qml dialog

Once we made customized buttons in the previous lesson , it is time to make the Custom Dialog, which will look more natively for Android devices, and can even look like the design on the IOS device. In any case, you will be able to more fully come to the realization of these devices guides.

To create a dialog object to be used Dialog of QtQuick.Dialog library. Nuance of A when working with custom dialog for Android is that the Standard Buttons that adequately look at the development of a desktop, for they look bad for Android, and more difficult to customize them for a beginner developer. The easiest way to implement your own buttons with their own stylization.

Development of Custom Dialog

Development of customized dialogue will continue on the basis of the project from the previous lesson. There we have two Custom Button have been created that we have a little tweak in color, so they looked concisely in relation to the dialogue. Also, using the technique in their styling, Styling dialog box button, which will be two buttons: "OK" and "Cancel". These buttons will close the dialog.

Dialog buttons will need to arrive at the bottom of the dialog, and the rest give a message "Hello, World !!!", as well as the section's button gray line with each other, and the same line will separate the buttons on the message. It will seem a bit on the IOS dialogue. As the line will be the Rectangle rectangle, the same technique is applied in the development of Android on Java, but instead of QML uses XML layout.

In order to make a customized normal contents of the dialog box, you must specify its parameter contentItem the object that will replace the contents. The most convenient is the Rectangle object, as early as it will place all other objects. Naturally no standard buttons there already and will not be in sight, so you can forget about them, but it is not a great loss indeed.

Evgenij LegotskojOct. 12, 2015, 11:15 a.m.

QMLQML - Lesson 002. Custom Button in QML Android

Android, qml, qml button, qml button android, qml custom button, qml custom button android, qt, qt qml

I will begin a series of lessons on QML Android to customize a button, or better to say with styling, as in this case the term is more appropriate. We will not invoke the dialog boxes in this tutorial, but just do your QML Cutom Button , which will change color when you click on it. And there will be two for clarity, these buttons.

The first button will be red with a black border and black text, and when pressed, it will change the background color to black with red border and red text. The second button will have the same colors, but in the opposite sequence.

Project structure of QML Custom Button

The project is created in QtCreator as the application project with Qt Quick Quick Controls elements. In fact, there already is menyubar, multiple conversations and a couple of buttons. So, throw out all but two buttons and go to customize them.

And the structure of the project, in this case get the following:

  • QMLCutomButton.pro - project profile;
  • deployment.pri - deployment profile;
  • main.cpp - source file with main function;
  • qml.qrc - resource file for images, qml files and so on;
  • main.qml - main qml file;
  • MainForm.ui.qml - resource qml file for using with qml designer
Evgenij LegotskojOct. 8, 2015, 1:03 p.m.

QtGameDev on Qt - Tutorial 4. Collision Detection in Qt (2D)

GameDev, Qt, Collision, Коллизия

Collision detection is one of the important aspects in GameDev. As it relates to the Conflict absolutely everything: hit the enemy bullets, bullets hit your hero, the hero of the body crossing the walls, crossing the body of the hero with the opponents, etc. And the important point is that the hero does not get stuck in a foreign object, but like any other object, and must, in its simplest form, push on it to stay in place. It is for this purpose and is collision detection.

Evgenij LegotskojOct. 7, 2015, 11:26 a.m.

QtQt/C++ - Lesson 023. Moving QGraphicsItem on QGraphicsScene with mouse help

QGraphicsScene, Qt, Qt урок, перетаскивание, QGraphicsItem

Let's say that you make an application that will be displayed the elements of the network infrastructure on the graphic scene . The question is how to make the movement of these elements with the mouse, you have to implement drag and drop elements. In other words, take the item with the mouse and exercise his moving to another place graphic scene.

Project Structure

To illustrate an example of creating a new project and add the new class, inherited from QGraphicsItem .

  • MoveGraphicsItem.pro - the profile of the project;
  • main.cpp - launch files;
  • widget.h - header of the main window;
  • widget.cpp - file source of the main window;
  • moveitem.h - header graphic element;
  • moveitem.cpp - file source graphic;
  • widget.ui - form the main window.
Evgenij LegotskojOct. 6, 2015, 1:13 p.m.

QtQt WinAPI - Lesson 007. Working with ICMP Ping in Qt

WinAPI, Qt, ICMP, PING

Immediately I want to upset you, dear readers. Qt does not have the functionality to work with the ICMP protocol and therefore have to use for this purpose API target operating system. However, this is not surprising. The ICMP protocol is a low-level protocol, and to work with it requires the use of raw sockets, which are not implemented in Qt.

But this is not a particular problem, because the main target platform has the necessary API to implement ping packages. For example Microsoft provides the simple use of ICMP protocol based IcmpSendEcho function.

IcmpSendEcho

The IcmpSendEcho function sends an IPv4 ICMP echo request and returns any echo response replies. The call returns when the time-out has expired or the reply buffer is filled.

DWORD IcmpSendEcho(
  _In_     HANDLE                 IcmpHandle,
  _In_     IPAddr                 DestinationAddress,
  _In_     LPVOID                 RequestData,
  _In_     WORD                   RequestSize,
  _In_opt_ PIP_OPTION_INFORMATION RequestOptions,
  _Out_    LPVOID                 ReplyBuffer,
  _In_     DWORD                  ReplySize,
  _In_     DWORD                  Timeout
);
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
SN

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

  • Result:10points,
  • Rating points-10
k
  • knobu
  • Sept. 23, 2020, 2:34 a.m.

C++ - Test 006. Enumerations

  • Result:60points,
  • Rating points-1
k
  • knobu
  • Sept. 23, 2020, 2:21 a.m.

C++ - Test 005. Structures and Classes

  • Result:91points,
  • Rating points8
Last comments
DI

Qt/C++ - Lesson 015. QTableWidget – How to create a table with checkboxes?

Кто-нибудь знает, как сделать так, чтобы в QTableWidget состоящей из чекбоксов в строке таблицы можно было выбрать только один checkbox ?

Qt/C++ - Lesson 006. QSqlQueryModel – Tables in Qt with SQL-query

QSqlTableModel выполняет ряд стандартных операций для одной таблицы из базы данных. Поэтому там и реализован функционал по удалению и редактированию. QSqlQueryModel позволяет выполнить запр…
VB

Qt/C++ - Lesson 006. QSqlQueryModel – Tables in Qt with SQL-query

Добрый день. Хотел спросить вот что. Создал проект на основе QAbstractTableModel. В MainWindow cоответственно создал модель и связал с представлением. Поиск веду по списку элементов модели,…

QCheckBox в качестве делегата QTableView

До тех пор, пока у вас проект содержит только одну таблицу, или несколько то может быть. Когда их будет 1000 и чекбоксы в разных колонках, то без делегатов и переопределения возвращаемых ре…
D
  • Damir
  • Sept. 20, 2020, 3:34 p.m.

QCheckBox в качестве делегата QTableView

bool Node::setData(const QModelIndex& index, const QVariant& value, int role){ switch (index.column()) { case 0: switch (role) { case Qt::CheckStateRole:// <- т…
Now discuss on the forum
DI

Как в QTableWidget, состоящей из чекбоксов, в строке таблицы можно было выбрать только один checkbox ?

Сделал таблицу состоящую из чекбоксов по уроку https://evileg.com/ru/post/78/ Кто-нибудь знает, как сделать так, чтобы в QTableWidget состоящей из чекбоксов в строке таблицы можно …
U

как скрыть елемент с копии виджета

Удалить пост нельзя... Поэтому удачки, Катту)
H

Тесты падают при сборке под MinGW.

Всем привет! При сборке под MinGW некоторые тесты при старте выдают FATAL "не удалось запустить тест проекта" и подвешивают Qt Creator - приходится его перезапускать. При сборке под MSVC та…

Как в qml работать с динамически созданными потомками?

Спасибо) В Qt/С++ есть функция deleteLater, которую обычно используют, чтобы удалить объекты, которые наследованы от QObject . Она добавлена для того, чтобы не удалять такие…

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

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