Sept. 14, 2015, 12:36 p.m.

Qt

QGraphicsItem, QGraphicsItem example, QGraphicsItem Qt, QGraphicsItem слот, Qt, множественное наследование

Let's talk a little about the inheritance from QGraphicsItem and application of signals and slots system in interaction with graphical objects on the graphic scene QGraphicsScene . The objective of this lesson is to create an application that on the graphic scene to be displayed object class QGraphicsItem , by clicking on which will appear QMessageBox dialog box signaling the event clicking on the graphic.

The project structure to work with QGraphicsItem

The structure of the project include:

  • TestPoint.pro - profile;
  • mainwindow.h - header file of the main application window;
  • mainwindow.cpp - file source code of the main application window;
  • mypoint.h - header code of the class inherited from QGraphicsItem;
  • mypoint.cpp - respectively, the source code;
  • main.cpp - master file from which you start the application, in the classroom is not considered as created by default;
  • mainwindow.ui - design file of the main window.
Sept. 12, 2015, 12:12 p.m.

Qt

QGraphicsScene, QGraphicsScene пример, Qt, QGraphicsScene Qt5, QGraphicsScene example

From this article we begin to explore the Qt graphic libraries, to be exact, QGraphicsScene. This class provides the functionality to manage a large number of 2D objects. QGraphicsScene set to QGraphicsView.

We describe the features that need to be implemented in our application:

  • Adding a graphic scene in QGraphicsView.
  • Rendering the graphics objects on the two stage via lines, namely a rectangle and a square.
  • Dynamic resizing of graphic scenes, depending on changes QGraphicsView sizes.
  • Dynamically changing objects on the graphic scene, depending on the size of the graphic scene.

Project Structure for QGraphicsScene

Project Structure for QGraphicsScene

By the project structure "Default" added another class MyGraphicView .

The fact is that for the convenience of working with QGraphicsScene it was decided to create a class that inherits from QGraphicsView already inside to operate graphical scene and its objects.

Sept. 4, 2015, 11:54 a.m.

Qt

qcheckbox, qcheckbox center, Qt, QTableWidget

One of the first problems in working with The QTableWidget , which are trying to solve, start to work with this widget - setting QCheckBox in the middle of the cell. The fact that the standard check box in QTableWidget checkbox attached to the left edge of the cell, while the right side is given for explanatory text. But the text may not be, but the area still remains. But at the same time it allows you to set QTableWidget in his cell widgets, which we use to solve this problem.

This article is an extension of a previous article on working with QTableWidget , therefore, to see the full code of the project I encourage you also to the article. This article provides only the code necessary to solve the problem.

Project Structure for QCheckBox center

Project structure remains the same as in the previous article .

mainwindow.ui

The form for the application window QCheckBox

In the main application will be placed:

  • QTableWidget
  • QLable
Sept. 4, 2015, 11:30 a.m.

Qt

Qt, Qt Таблица, QTableWidget, QTableWidget example, QTableWidget пример

Using QTableWidget will be the first in a manner that will advise you to create tables with checkboxes on Qt. So let's look at this option and work with tables in Qt and certainly applicable checkboxes.

So, the lesson to be more close to reality, grabbed some code from lesson QDataWidgetMapper . Namely, take a class to work with the database, so they'd just do a table from the database. After that, make the shape of the main application window and output data from the table with the mapping checkboxes. Naturally, when the application database table is created and populated by several records, which we will display in the widget.

Project Structure for QTableWidget

I suggest to get acquainted with the project structure:

  • QTableWidgetExample.pro - profile;
  • mainwindow.h - header file of the main application window;
  • mainwindow.cpp - source of window;
  • main.cpp - the main source file from which the application starts;
  • mainwindow.ui - form of the main application window;
  • database.h - header file of helper class to be used for information that is placed in a database;
  • database.cpp - source of helper class file to be used for information that is placed in a database;
Sept. 1, 2015, 11 a.m.

Qt

QPushButton, Dynamic widget, Динамический виджет, Qt

In complex projects may not be enough to have a static widget in the interface as the incoming information can change every second. Therefore the question on creation of dynamic widgets, such as the layout Qt buttons.

This tutorial describes how to dynamically create QPushButton buttons, receiving signals from these buttons, and the subsequent removal of these buttons from the layout Qt.

Project Structure

Description of the Project:

  • DynamicButtons.pro - profile;
  • mainwindow.h - header file of the main application window;
  • mainwindow.cpp - source of window;
  • main.cpp - the main source file from which the application starts;
  • mainwindow.ui - form of the main application window;
  • qdynamicbutton.h - header file of the wrapper class, which simplifies the process of working with dynamic objects in this lesson;
  • qdynamicbutton.cpp - source file wrapper class that simplifies the process of working with dynamic objects in this lesson.
Aug. 31, 2015, 10:39 a.m.

Qt

QMenu, QMenu example, QMenu Qt, Qt, контекстное меню, меню

To use the context menu in Qt is used QMenu class. When performing actions that should cause the menu handler is called, which creates the menu and binds handlers to act in this menu.

In this lesson, work with the shortcut menu will be shown in the example code from the tutorial on working with QDataWidgetMapper. In this lesson, the two files from the previous lesson will be modified, but the project will not work if you do not include it as in the previous lesson files that can not be edited.

Project structure for QMenu

Project structure remains the same as in the tutorial, which is based on the lesson. Changes in the code will be subjected to only two files:

  • mainwindow.h
  • mainwindow.cpp
Aug. 30, 2015, 10:33 a.m.

Qt

QShortcut, QShortcut example, Qt

Even in the official documentation on the topic QShortcut written not so much, so it's probably a note not to forget, not a full-fledged article. Just a few words about how to connect QShortcut entity that will be responsible for processing pressing a hotkey or keyboard shortcuts, such as Ctrl + D .

Project structure for QShortcut

The project structure is so trivial that I will not even bring it in this article. I shall confine myself to only those words that we will work with two files:

  • mainwindow.h
  • mainwindow.cpp

And even mainwindow.ui file will not touch this project. As it will be created by default, so it and leave.

Aug. 28, 2015, 9:34 a.m.

Qt

Qt, QXmlStreamReader, QXmlStreamWriter, XML, xml example

Qt development tools include functionality for working with XML files, which allows you to create XML files and read them, which may be useful to create the automatic creation of XML markup software, configuration files, using XML, or for parsing XML-files .

To record in an XML file format used QXmlStreamWriter class, while the other is used QXmlStreamReader class to read an XML file.

The project structure for working with XML file

This project uses the minimum number of files:

  • XMLExample.pro - profile;
  • mainwindow.h - header file of the main application window;
  • mainwindow.cpp - source of window;
  • main.cpp - the main source file from which the application starts;
  • mainwindow.ui - form of the main application window;
Aug. 26, 2015, 9:15 a.m.

Qt

QPallete, QSplitter, QSplitter color, QSplitter example, Qt

Qualitative layout always increases application usability, and this is true for all kinds of applications, from desktop to mobile. One such interface elements, which can improve usability is QSplitter class, which is an object-type layout with a movable divider that separates the two areas in the application interface.

Project Structure for QSplitter

Project Structure for QSplitter

Project structure completely unremarkable and a little interesting, since the main actions will be carried out in the designer, and QSplitter in mainwindow.cpp setting will produce a minimum.

Aug. 20, 2015, 8:45 a.m.

Qt

Qt, Qt урок, QTimer, QTimer example, QTimer таймер

Few talk about the use of class QTimer in Qt. This is a small lightweight theme after a series of articles about QSqlTabelModel volume and the resulting consequences of it.

Timers we may need to create a poll LAN devices via TCP / IP stack with certain intervals or hourly data validation or active connections to the server. Yes to anything !? And here we come to the aid QTimer, which we consider the example of output every second time QLabel.

Project structure

We use a minimum of files in our project:

  • QDataMapperWidget.pro
  • mainwindow.h - header file of the main application window;
  • mainwindow.cpp -source window;
  • main.cpp - the main source file from which the application starts;
  • mainwindow.ui - form of the main application window;

A draw form in the Designer Qt Creator. But there is nothing to draw. QLabel thrown into the middle and ready.

AS
July 22, 2019, 4:32 p.m.
Aleksandr Spiridonov

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

  • Result:46points,
  • Rating points-6
AS
July 22, 2019, 4:21 p.m.
Aleksandr Spiridonov

Qt - Test 001. Signals and slots

  • Result:73points,
  • Rating points1
July 22, 2019, 10 a.m.
Pavel K.

C++ - Test 006. Enumerations

  • Result:50points,
  • Rating points-4
Last comments
July 21, 2019, 6:03 a.m.
Evgenij Legotskoj

да, наверное, 32-х разрядную поддержку уже давно поа было выкинуть. К слову, у вас много проектов под Android? Часто много где вижу вопросы о том, пишет ли кто-то вообще на Qt под мобильные сист…
July 20, 2019, 2:41 p.m.
Andrej Jankovich

Очень полезная информация, увы уже выкинул поддержку 32 битных бедняг.
July 20, 2019, 9:31 a.m.
Mihailll

Вот так qDebug()<<"position:"<<event->scenePos();
July 20, 2019, 8:49 a.m.
Mihailll

Добрый день. Как можно узнать координату на графической сцене при отпускании клавиши мыши?
Now discuss on the forum
July 22, 2019, 10:50 a.m.
Pavel K.

Благодарю.Буду пробовать.
July 22, 2019, 10:10 a.m.
Pavel K.

Скорее всего в коде не правильно потоки используются. на форуме пишут кое что интересное - https://stackoverflow.com/questions/18112027/qt-5-1-qml-property-through-threads
July 22, 2019, 3:58 a.m.
Evgenij Legotskoj

Добрый день! Нужен совет сообщества по разработке функционала проверки орфографии. Одна из идей - добавить проверку орфографии при наборе текста статей. Полагаю, что наиболее аде…
July 22, 2019, 3:01 a.m.
Evgenij Legotskoj

Возможно, если при сохранении файла установить права доступа на файл. Что-то такое должно быть у QFile
Looking for a Job?
5,000.00 руб. - 15,000.00 руб.
Дизайнер
Moskovskiy, Moscow, Russia
25,000.00 руб. - 30,000.00 руб.
Разработчик Qt/C++
Barnaul, Altai Krai, Russia

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

EVILEG
About
Services
Join us
© EVILEG 2015-2019
Recommend hosting TIMEWEB