C++ (Qt)#include <QMessageBox>#include <QSqlError>#include <QSqlQuery> #include "sprmu.h"#include "ui_sprmu.h" sprMU::sprMU(QWidget *parent) : QDialog(parent), ui(new Ui::sprMU){ ui->setupUi(this); ui->splitter_2 -> setStretchFactor(0,0); ui->splitter_2 -> setStretchFactor(1,1); ui->splitter_2 -> setStretchFactor(2,2); createButtons(); //createActions(); // ------- Отображаем Группы МУ GroupMUModel = new QSqlQueryModel(this); GroupMUModel->setQuery("SELECT MUGroupCode, MUGroupName , MUGroupId " "FROM sprMUGroup " "ORDER BY 1"); if(GroupMUModel -> lastError().isValid()){ QMessageBox::critical(this,tr("Ошибка SQL"),GroupMUModel -> lastError().text()); return; } ui->GroupMUView -> setModel(GroupMUModel); // ------- Отображаем Подгруппы МУ UnGroupMUModel = new QSqlQueryModel(this); UnGroupMUModel -> setQuery("SELECT * " "FROM sprMUUnGroup "); if(UnGroupMUModel -> lastError().isValid()){ QMessageBox::critical(this,tr("Ошибка SQL"),UnGroupMUModel -> lastError().text()); return; } ui->UnGroupMUView -> setModel(UnGroupMUModel); // ------- Отображаем мед. услуги MUModel = new QSqlQueryModel(this); MUModel -> setQuery("SELECT * FROM sprMU "); if(MUModel -> lastError().isValid()){ QMessageBox::critical(this,tr("Ошибка SQL"),MUModel -> lastError().text()); return; } ui->MUView -> setModel(MUModel); } sprMU::~sprMU(){ delete ui;} void sprMU::changeEvent(QEvent *e){ QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; }} void sprMU::createButtons(){ ui->GroupRefrButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupAddButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupEditButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupDelButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); connect(ui->GroupAddButt,SIGNAL(clicked()),this,SLOT(slotAddGroupMU())); } void sprMU::slotAddGroupMU(){ QMessageBox::information(this,"","");}
#include <QMessageBox>#include <QSqlError>#include <QSqlQuery>#include "sprmu.h"#include "ui_sprmu.h"sprMU::sprMU(QWidget *parent) : QDialog(parent), ui(new Ui::sprMU){ ui->setupUi(this); ui->splitter_2 -> setStretchFactor(0,0); ui->splitter_2 -> setStretchFactor(1,1); ui->splitter_2 -> setStretchFactor(2,2); createButtons(); //createActions();
}sprMU::~sprMU(){ delete ui;}void sprMU::changeEvent(QEvent *e){ QDialog::changeEvent(e); switch (e->type()) { case QEvent::LanguageChange: ui->retranslateUi(this); break; default: break; }}void sprMU::createButtons(){ ui->GroupRefrButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupAddButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupEditButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); ui->GroupDelButt -> setStyleSheet("QPushButton {border: none;padding: 4px;} QPushButton:hover {border: 2px outset #8f8f91;border-radius: 4px;} QPushButton:pressed {border: 2px inset #8f8f91;border-radius: 4px;}"); connect(ui->GroupAddButt,SIGNAL(clicked()),this,SLOT(slotAddGroupMU()));}void sprMU::slotAddGroupMU(){ QMessageBox::information(this,"","");}
Ваш_Класс::Конструктор{ // прописываем все ui методы (создание кнопок, формы, настройка их) // далее создаем поток загрузки (потомок от QThread в моем случае) LoadThread * thread = new QThread();}