Aug. 7, 2019, 10:41 a.m.

Development diaries

QTableWidget, QThread

Список АЗС с которыми будем производить дальнейшие действия мы получили.
Создаем слот вызываемый при нажатии на CheckBox на на GroupBox Действия.

void FuelNameDialog::on_groupBoxActions_clicked(bool checked)
{
    if(checked){
        //Очищаем список терминалов передаваемых для дальнейшей обработки
        listTerminals.clear();
        //Добавляем отмеченные терминалы в список
        int rowCount = ui->tableWidgetTerm->rowCount();
        for(int i=0; i<rowCount; ++i){
            QWidget *item = ui->tableWidgetTerm->cellWidget(i,0);
            QCheckBox *checkBox = qobject_cast<QCheckBox*>(item->layout()->itemAt(0)->widget());
            if(checkBox->isChecked()){
               listTerminals.append(ui->tableWidgetTerm->item(i,1)->data(Qt::DisplayRole).toInt());
            }
        }
        //Проверяем что список не пустой
        if(listTerminals.size()==0){
            QMessageBox::warning(this, "Ошибка ввода","Нет выбранных терминалов");
            ui->groupBoxActions->setChecked(false);
            return;
        }
    }
    ui->groupBoxFuel->setEnabled(!checked);
}
April 17, 2019, 3:58 a.m.
Ruslan Polupan

Qt

Доброго времени суток!

Нужен совет по много поточности.
Есть вот такая вот табличка.

Столбец статуc хотелось бы получать в потоке для всех записей (АЗС).
Для одной записи я реализовал получение статуса сервера базы данных.

Вопрос в том как делать это д…

Nov. 20, 2018, 7:42 a.m.

Qt

QThread, Qt, QAbstractTableModel, QSqlQuery

There was a need to obtain a large amount of data from the database for the subsequent work of the user with them (Reference book of goods in a particular store).

For the code do not kick much. Programming for me is a hobby for the mind.

The query itself takes a long time. For this, we do it in the stream, display the endless ProgressBar to the user with the sentence "Lean back and wait." :-)

F
Feb. 14, 2018, 12:06 p.m.
Fynjy

Qt

Привет ВСем! Итак вопрос такой: Есть класс, в полях которого есть указатель на объект наследник от QDialog. Я создаю обьект основного класса, в конструкторе этого класса я создаю обьект в динамической памяти - указатель на наследника QDialog. Обьеект оснновного класса далее я перевожу из GUI п…

M
Nov. 15, 2017, 9:03 a.m.
Misha

Qt

Здравствуйте.

Одна из функций обрабатывает массивы и постоянно изменяет переменные, записанные в хедере. Переменные изменяются другими функциями. В хедере записано, т.к. к этим переменным постоянно обращаются различные функции.
Обработка массивов требует большой вычислительной мощн…
Oct. 23, 2017, 3:22 a.m.

Qt

Qt, QSerialPort, QThread

I had the task of writing software for controlling the radiator of the X-ray. Namely: realize the protocol of data transfer between the PC and the radiator of the X-ray and create the user-defined functions "Set parameters", "Enable X-ray", "Switch off X-ray".

The X-ray radiator is controlled by data transfer via the serial port, which is also called a COM port, but it is applicable only for Windows.

Qt has the QSerialPort class, which provides functions for accessing the serial port.
I want to show you my implementation of this task.

May 15, 2016, 7:11 a.m.

Qt

moveToThread, QObject, Qt, QThread, потоки

In a previous article we are only a little touch to working with threads , and in the version that is more for the customization of thread, although it can be used to perform outside work not directly related to the thread. That is an option with inheritance from QThread and override the method run().

Now we will create ExampleObject class whose objects will be transferred to the individual threads via moveToThread() method and implemented in most of these flows. A useful work will make the slot method run() , which will be defined in this class. What is important, object class will inherit from QObject .

In order to work in the run() method can be performed in cycles, using a while loop, which will operate using variable bool m_running. For the convenience of working with this variable we define it as Q_PROPERTY . But at the end of the work will emit finished() signal.

May 9, 2016, 1:12 p.m.

Qt

Qt, QThread, потоки

One of the most common ways to create a separate parallel threads in an application to Qt , and perform useful tasks in them is the inheritance of QThread class and override the method run() , which will be carried out and useful application code. When meeting with threads have read different opinions on this subject, and in this lesson will get acquainted with one of the possible ways to work with streams, but which are not considered to be the best option.

In general, if we make the class inherit from the QThread , it is logical to assume that this is done with the intention that it is not sufficient functionality of the class. But when this is done only with the aim to bring in, which must be performed in a separate thread run() method a useful code, then there is clearly something wrong. In addition, de might be a problem with scaling applications and reuse code, particularly hard this can be shown in the case where such inherited class becomes quite a lot.

This method is the low level, and is used primarily for customization native streams. What is somewhat contrary to the usual need to complete a task in a separate thread. That is, as mentioned above, such an approach is primarily needed to extend the functionality class. Nevertheless, this method is necessary to consider what and proceed.

April 7, 2016, 1:05 p.m.

Qt

Qt, QThread, потоки

GUI thread and the worker thread

Each program has a single thread (thread) on startup. This thread is called the main flow thread or GUI in Qt applications. Qt GUI to be started in this thread. All widgets and several similar classes, such as a QPixmap, do not work in a secondary thread. The secondary flow is commonly called workflow, which is designed to relieve the basis of the program thread.

Concurrent access to data

If two threads are a pointer to an object, it is possible to access both threads to the object at a certain time and this may destroy the integrity of the object. It is necessary to prevent simultaneous access to the object from different threads.

D
Aug. 16, 2019, 12:58 p.m.
Damir

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

  • Result:92points,
  • Rating points8
D
Aug. 16, 2019, 12:46 p.m.
Damir

C++ - Test 005. Structures and Classes

  • Result:75points,
  • Rating points2
u
Aug. 14, 2019, 2:55 p.m.
unrealproro

C++ - Test 005. Structures and Classes

  • Result:83points,
  • Rating points4
Last comments
D
Aug. 17, 2019, 9:04 a.m.
Damir

github ChekableTView Правой групповая смена значения при перетаскивании левой как обычно.
Aug. 16, 2019, 1:03 p.m.
Evgenij Legotskoj

Потому, что в минуте 60 секунд
Aug. 16, 2019, 12:16 p.m.
Dmitrij

а почему делитель 60000, а не 1000?
g
Aug. 14, 2019, 1:27 a.m.
grig_p

Спасибо большое. Получилось
Aug. 13, 2019, 10:43 a.m.
Evgenij Legotskoj

Самая главная проблема в том, что у вас это константные переменные, и инициализируется они один единственный раз при запуске программы. Поэтому делать динамический перевод в таком случае у …
Now discuss on the forum
Aug. 18, 2019, 3:22 a.m.
Ruslan Polupan

Т.е. таблицы в БД к которым обращается приложение могут отсутсвовать?
Aug. 15, 2019, 3:19 a.m.
Mihailll

Плюсы и qml отличаются, с++ логичней
Aug. 14, 2019, 8:20 a.m.
Evgenij Legotskoj

Да это не столько баги QML, сколько поведение JavaScript, который используется в нём. Из-за отсутствия строгой типизации получаем некоторые проблемы с преобразованием типов. в итоге, на первый в…
Aug. 14, 2019, 2:33 a.m.
BlinCT

Ошибка найдена) недосмотрел.
Aug. 13, 2019, 3:52 a.m.
Evgenij Legotskoj

Бери остаток от деления #include <QCoreApplication>#include <QTime>#include <QDebug>int main(int argc, char *argv[]){ QCoreApplication a(argc, argv); QTime time…
Looking for a Job?
14,000.00 руб. - 40,000.00 руб.
Разработчик Qt
Annino, Moscow Oblast, Russia
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