Advanced search
Evgenij LegotskojJune 15, 2017, 2:58 a.m.

QtQt/C++ - Tutorial 067. Using QMultiMap for a dictionary of synonyms

Qt, QStandardItemModel, QMultiMap, QTableView

QMultiMap is a class inherited from QMap, which allows you to store multiple values for a single key. That is, the key can be repeated. This class can be used, for example, to represent a dictionary of synonyms.

Let's write a small program that will contain two tables:

  1. A table with keys
  2. A table with values that will be synonymous with words in the first table.

Initially, the table with the keys will be filled, while the table with the values will be empty. When you click on a row in the key table, the value table will be filled with synonyms of the word whose string was clicked.

Appearance of the application:

Evgenij LegotskojMarch 30, 2017, 1:47 p.m.

QtQt/C++ - Lesson 061. Adding images to the application using the Drag And Drop method from the file manager

QDropEvent, QStyledDelegate, QStandardItemModel, QListView

Let's write a small application that will allow Drag and Drop to drag and drop images from the file manager into the application itself. In this application, there will be an image preview area and a list of all the images that we put into our application. In this case, when clicking on the image in the list, the image will be placed in the main view area, by which we clicked. In this list, each element will have a preview of the image without text. This preview will be generated using a delegate inherited from QStyledDelegate .

The application will look like this:

Evgenij LegotskojJan. 22, 2017, 10:33 a.m.

QtQt/C++ - Lesson 059. Do I need to delete QStandardItem object from the memory after the call clear method in a data model?

QStandardItem, QStandardItemModel

When working with tables, and generally with different data in C ++ requires control over the removal to avoid memory leaks. But whether you want a total control of the removal of QStandardItem objects placed in QStandardItemModel , which has caused a clear method?

Such a question may arise on the basis of the manner in which QStandardItem objects are usually added in QStandardItemModel , namely:

QList<QStandardItem *> items;
items.append(new QStandardItem("Item 1"));
items.append(new QStandardItem("Item 2"));
items.append(new QStandardItem("Item 3"));

And so on in the cycle to fill the required number of rows. At the same pointers to data objects anywhere in the code will no longer appear and are not removed. Therefore, the question arises as to what happens if you call a clear method.

When an QStandardItem object is passed to QStandardItemModel , the ownership of these assets are transferred to the model. And when the method is clear model automatically removes the objects from memory.

Konstantin LazarevJan. 6, 2017, 2:40 p.m.

QtРабота с таблицами

Qt, QStandardItem, QStandardItemModel, QTableView

Подскажите пожалуйста, как работать с таблицами. Как сделать заполнение ячеек текстом.

Evgenij LegotskojAug. 28, 2016, 11:08 a.m.

QtQt/C++ - Lesson 054. Reading data from a CSV file, and their representation via QStandardItemModel

CSV, QStandardItemModel, Qt, QTableView

CSV data format ( Comma-Separated Values ) format is the simplest representation of tabular data. This format is supported by Excel and many other office suites. For example, I often encounter this format when uploading statistics do the site of the panel webmasters Google Search Console.

In this format, the table represents the data sequence, separated by commas, and represent the column and row are separated by a newline. In the case of the Russian-language Microsoft Excel data separated by semicolons and will be as follows:


Parsing CSV

So the whole problem is reduced to a line reading data from a file and uploads the data model of data presentation, which will be placed in QTableView .

Let us take as a basis the above example, the contents of a CSV file that was created in Microsoft Excel:

And display it in QTableView via QStandardItemModel:

Evgenij LegotskojJune 29, 2016, 9:06 a.m.

QtQt/C++ - Lesson 051. QMediaPlayer – simple audio player

QMediaPlayer, QMediaPlaylist, QStandardItemModel, Qt, аудио плеер

I suggest to write a simple audio player for mp3 files using Qt/C++, which will have a playlist, the ability to start / pause / stop tracks, as well as scroll through the tracks.

For the implementation of this ideas in Qt, classes are QMediaPlayer and QMediaPlaylist, which belong to the multimedia module. And to display the playlist and use QStandardItemModel QTableView.

Articles in this series:

Project structure

  • - the profile of the project;
  • main.cpp - the file with the main function;
  • widget.ui - form of application window;
  • widget.h - header file of the application window;
  • widget.cpp - file source code of the application window;
  • buttons.qrc - resource file application icon buttons.
How to become an author?

Contribute to the evolution of the EVILEG community.

Learn how to become a site author.

Learn it

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


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

C++ - Test 002. Constants

  • Result:75points,
  • Rating points2

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

  • Result:73points,
  • Rating points1

C++ - Test 005. Structures and Classes

  • Result:75points,
  • Rating points2
Last comments

Django - Tutorial 027. Implementation Google reCAPTCHA

Спасибо. Только использую декоратор не в а перед views

Qt WinAPI - Lesson 001. How to collect all DLL, which used in Qt project?

Вы меня не совсем правильно поняли, но все равно спасибо, принял все к сведению. Все сделал как вы сказали, все отлично работает, еще раз огромнейшее спасибо) Разве что только что были опять про…

Qt WinAPI - Lesson 001. How to collect all DLL, which used in Qt project?

Стоило перед использованием что ли инструкцию прочитать "После сборки при запуске требовались dll," Ясное дело стоило задепло…

Qt WinAPI - Lesson 001. How to collect all DLL, which used in Qt project?

Да, собралось. После сборки при запуске требовались dll, перекинул всю папки bin, plugins(не знаю как можно было сделать более умно). Как я понял в первой строке путь к екзешнику вставляю, втор…
Now discuss on the forum

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

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

Qt C++ и Python

Красиво/некрасиво - это скорее моё личное отношение. Если есть возможность ограничить количество интсрументов, то лучше ограничить. Но не зацикливайтесь на этом. Если у вас есть скрипты Py…

Qt + OpenGL glDeleteVertexArrays

Я не уверен, поскольку с OpenGL очень мало работал. Но может быть OpenGL контекст виджета нужно переинициализовывать. И ещё виджет стоит удалять через метод deleteLater() а не п…

QWebEngineView не запускается если к ПК подключено несколько мониторов

Ну я имел ввиду посмотреть на другом ПК с другой графикой и парой мониторов. Как моей программе назначить использовать определенный граф. адаптер? Вот тут понятия не имею.

Счечик производительности сети

Хорошо. После работы сегодня гляну ваш код внимательно.
© EVILEG 2015-2020
Recommend hosting TIMEWEB