mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-04 00:05:25 +08:00
qt 6.5.1 original
This commit is contained in:
43
examples/sql/sqlbrowser/CMakeLists.txt
Normal file
43
examples/sql/sqlbrowser/CMakeLists.txt
Normal file
@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(sqlbrowser LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
if(NOT DEFINED INSTALL_EXAMPLESDIR)
|
||||
set(INSTALL_EXAMPLESDIR "examples")
|
||||
endif()
|
||||
|
||||
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sql/sqlbrowser")
|
||||
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Widgets)
|
||||
|
||||
qt_standard_project_setup()
|
||||
|
||||
qt_add_executable(sqlbrowser
|
||||
browser.cpp browser.h
|
||||
browserwidget.ui
|
||||
connectionwidget.cpp connectionwidget.h
|
||||
main.cpp
|
||||
qsqlconnectiondialog.cpp qsqlconnectiondialog.h qsqlconnectiondialog.ui
|
||||
)
|
||||
|
||||
set_target_properties(sqlbrowser PROPERTIES
|
||||
WIN32_EXECUTABLE TRUE
|
||||
MACOSX_BUNDLE TRUE
|
||||
)
|
||||
|
||||
target_link_libraries(sqlbrowser PRIVATE
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Sql
|
||||
Qt6::Widgets
|
||||
)
|
||||
|
||||
install(TARGETS sqlbrowser
|
||||
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
|
||||
)
|
268
examples/sql/sqlbrowser/browser.cpp
Normal file
268
examples/sql/sqlbrowser/browser.cpp
Normal file
@ -0,0 +1,268 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "browser.h"
|
||||
#include "qsqlconnectiondialog.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtSql>
|
||||
|
||||
Browser::Browser(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
table->addAction(insertRowAction);
|
||||
table->addAction(deleteRowAction);
|
||||
table->addAction(fieldStrategyAction);
|
||||
table->addAction(rowStrategyAction);
|
||||
table->addAction(manualStrategyAction);
|
||||
table->addAction(submitAction);
|
||||
table->addAction(revertAction);
|
||||
table->addAction(selectAction);
|
||||
|
||||
if (QSqlDatabase::drivers().isEmpty())
|
||||
QMessageBox::information(this, tr("No database drivers found"),
|
||||
tr("This demo requires at least one Qt database driver. "
|
||||
"Please check the documentation how to build the "
|
||||
"Qt SQL plugins."));
|
||||
|
||||
emit statusMessage(tr("Ready."));
|
||||
}
|
||||
|
||||
Browser::~Browser()
|
||||
{
|
||||
}
|
||||
|
||||
void Browser::exec()
|
||||
{
|
||||
QSqlQueryModel *model = new QSqlQueryModel(table);
|
||||
model->setQuery(QSqlQuery(sqlEdit->toPlainText(), connectionWidget->currentDatabase()));
|
||||
table->setModel(model);
|
||||
|
||||
if (model->lastError().type() != QSqlError::NoError)
|
||||
emit statusMessage(model->lastError().text());
|
||||
else if (model->query().isSelect())
|
||||
emit statusMessage(tr("Query OK."));
|
||||
else
|
||||
emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
|
||||
model->query().numRowsAffected()));
|
||||
|
||||
updateActions();
|
||||
}
|
||||
|
||||
QSqlError Browser::addConnection(const QString &driver, const QString &dbName, const QString &host,
|
||||
const QString &user, const QString &passwd, int port)
|
||||
{
|
||||
static int cCount = 0;
|
||||
|
||||
QSqlError err;
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase(driver, QString("Browser%1").arg(++cCount));
|
||||
db.setDatabaseName(dbName);
|
||||
db.setHostName(host);
|
||||
db.setPort(port);
|
||||
if (!db.open(user, passwd)) {
|
||||
err = db.lastError();
|
||||
db = QSqlDatabase();
|
||||
QSqlDatabase::removeDatabase(QString("Browser%1").arg(cCount));
|
||||
}
|
||||
connectionWidget->refresh();
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void Browser::addConnection()
|
||||
{
|
||||
QSqlConnectionDialog dialog(this);
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
|
||||
if (dialog.useInMemoryDatabase()) {
|
||||
QSqlDatabase::database("in_mem_db", false).close();
|
||||
QSqlDatabase::removeDatabase("in_mem_db");
|
||||
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "in_mem_db");
|
||||
db.setDatabaseName(":memory:");
|
||||
if (!db.open())
|
||||
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
|
||||
"opening the connection: ") + db.lastError().text());
|
||||
QSqlQuery q("", db);
|
||||
q.exec("drop table Movies");
|
||||
q.exec("drop table Names");
|
||||
q.exec("create table Movies (id integer primary key, Title varchar, Director varchar, Rating number)");
|
||||
q.exec("insert into Movies values (0, 'Metropolis', 'Fritz Lang', '8.4')");
|
||||
q.exec("insert into Movies values (1, 'Nosferatu, eine Symphonie des Grauens', 'F.W. Murnau', '8.1')");
|
||||
q.exec("insert into Movies values (2, 'Bis ans Ende der Welt', 'Wim Wenders', '6.5')");
|
||||
q.exec("insert into Movies values (3, 'Hardware', 'Richard Stanley', '5.2')");
|
||||
q.exec("insert into Movies values (4, 'Mitchell', 'Andrew V. McLaglen', '2.1')");
|
||||
q.exec("create table Names (id integer primary key, FirstName varchar, LastName varchar, City varchar)");
|
||||
q.exec("insert into Names values (0, 'Sala', 'Palmer', 'Morristown')");
|
||||
q.exec("insert into Names values (1, 'Christopher', 'Walker', 'Morristown')");
|
||||
q.exec("insert into Names values (2, 'Donald', 'Duck', 'Andeby')");
|
||||
q.exec("insert into Names values (3, 'Buck', 'Rogers', 'Paris')");
|
||||
q.exec("insert into Names values (4, 'Sherlock', 'Holmes', 'London')");
|
||||
connectionWidget->refresh();
|
||||
} else {
|
||||
QSqlError err = addConnection(dialog.driverName(), dialog.databaseName(), dialog.hostName(),
|
||||
dialog.userName(), dialog.password(), dialog.port());
|
||||
if (err.type() != QSqlError::NoError)
|
||||
QMessageBox::warning(this, tr("Unable to open database"), tr("An error occurred while "
|
||||
"opening the connection: ") + err.text());
|
||||
}
|
||||
}
|
||||
|
||||
void Browser::showTable(const QString &t)
|
||||
{
|
||||
QSqlTableModel *model = new CustomModel(table, connectionWidget->currentDatabase());
|
||||
model->setEditStrategy(QSqlTableModel::OnRowChange);
|
||||
model->setTable(connectionWidget->currentDatabase().driver()->escapeIdentifier(t, QSqlDriver::TableName));
|
||||
model->select();
|
||||
if (model->lastError().type() != QSqlError::NoError)
|
||||
emit statusMessage(model->lastError().text());
|
||||
|
||||
table->setModel(model);
|
||||
table->setEditTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed);
|
||||
connect(table->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||
this, &Browser::currentChanged);
|
||||
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void Browser::showMetaData(const QString &t)
|
||||
{
|
||||
QSqlRecord rec = connectionWidget->currentDatabase().record(t);
|
||||
QStandardItemModel *model = new QStandardItemModel(table);
|
||||
|
||||
model->insertRows(0, rec.count());
|
||||
model->insertColumns(0, 7);
|
||||
|
||||
model->setHeaderData(0, Qt::Horizontal, "Fieldname");
|
||||
model->setHeaderData(1, Qt::Horizontal, "Type");
|
||||
model->setHeaderData(2, Qt::Horizontal, "Length");
|
||||
model->setHeaderData(3, Qt::Horizontal, "Precision");
|
||||
model->setHeaderData(4, Qt::Horizontal, "Required");
|
||||
model->setHeaderData(5, Qt::Horizontal, "AutoValue");
|
||||
model->setHeaderData(6, Qt::Horizontal, "DefaultValue");
|
||||
|
||||
for (int i = 0; i < rec.count(); ++i) {
|
||||
QSqlField fld = rec.field(i);
|
||||
model->setData(model->index(i, 0), fld.name());
|
||||
model->setData(model->index(i, 1), fld.typeID() == -1
|
||||
? QString(fld.metaType().name())
|
||||
: QString("%1 (%2)").arg(fld.metaType().name()).arg(fld.typeID()));
|
||||
model->setData(model->index(i, 2), fld.length());
|
||||
model->setData(model->index(i, 3), fld.precision());
|
||||
model->setData(model->index(i, 4), fld.requiredStatus() == -1 ? QVariant("?")
|
||||
: QVariant(bool(fld.requiredStatus())));
|
||||
model->setData(model->index(i, 5), fld.isAutoValue());
|
||||
model->setData(model->index(i, 6), fld.defaultValue());
|
||||
}
|
||||
|
||||
table->setModel(model);
|
||||
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
||||
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void Browser::insertRow()
|
||||
{
|
||||
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
QModelIndex insertIndex = table->currentIndex();
|
||||
int row = insertIndex.row() == -1 ? 0 : insertIndex.row();
|
||||
model->insertRow(row);
|
||||
insertIndex = model->index(row, 0);
|
||||
table->setCurrentIndex(insertIndex);
|
||||
table->edit(insertIndex);
|
||||
}
|
||||
|
||||
void Browser::deleteRow()
|
||||
{
|
||||
QSqlTableModel *model = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (!model)
|
||||
return;
|
||||
|
||||
QModelIndexList currentSelection = table->selectionModel()->selectedIndexes();
|
||||
for (int i = 0; i < currentSelection.count(); ++i) {
|
||||
if (currentSelection.at(i).column() != 0)
|
||||
continue;
|
||||
model->removeRow(currentSelection.at(i).row());
|
||||
}
|
||||
|
||||
updateActions();
|
||||
}
|
||||
|
||||
void Browser::updateActions()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
bool enableIns = tm;
|
||||
bool enableDel = enableIns && table->currentIndex().isValid();
|
||||
|
||||
insertRowAction->setEnabled(enableIns);
|
||||
deleteRowAction->setEnabled(enableDel);
|
||||
|
||||
fieldStrategyAction->setEnabled(tm);
|
||||
rowStrategyAction->setEnabled(tm);
|
||||
manualStrategyAction->setEnabled(tm);
|
||||
submitAction->setEnabled(tm);
|
||||
revertAction->setEnabled(tm);
|
||||
selectAction->setEnabled(tm);
|
||||
|
||||
if (tm) {
|
||||
QSqlTableModel::EditStrategy es = tm->editStrategy();
|
||||
fieldStrategyAction->setChecked(es == QSqlTableModel::OnFieldChange);
|
||||
rowStrategyAction->setChecked(es == QSqlTableModel::OnRowChange);
|
||||
manualStrategyAction->setChecked(es == QSqlTableModel::OnManualSubmit);
|
||||
}
|
||||
}
|
||||
|
||||
void Browser::about()
|
||||
{
|
||||
QMessageBox::about(this, tr("About"), tr("The SQL Browser demonstration "
|
||||
"shows how a data browser can be used to visualize the results of SQL"
|
||||
"statements on a live database"));
|
||||
}
|
||||
|
||||
void Browser::on_fieldStrategyAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->setEditStrategy(QSqlTableModel::OnFieldChange);
|
||||
}
|
||||
|
||||
void Browser::on_rowStrategyAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->setEditStrategy(QSqlTableModel::OnRowChange);
|
||||
}
|
||||
|
||||
void Browser::on_manualStrategyAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->setEditStrategy(QSqlTableModel::OnManualSubmit);
|
||||
}
|
||||
|
||||
void Browser::on_submitAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->submitAll();
|
||||
}
|
||||
|
||||
void Browser::on_revertAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->revertAll();
|
||||
}
|
||||
|
||||
void Browser::on_selectAction_triggered()
|
||||
{
|
||||
QSqlTableModel * tm = qobject_cast<QSqlTableModel *>(table->model());
|
||||
if (tm)
|
||||
tm->select();
|
||||
}
|
||||
|
83
examples/sql/sqlbrowser/browser.h
Normal file
83
examples/sql/sqlbrowser/browser.h
Normal file
@ -0,0 +1,83 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef BROWSER_H
|
||||
#define BROWSER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSqlTableModel>
|
||||
#include "ui_browserwidget.h"
|
||||
|
||||
class ConnectionWidget;
|
||||
QT_FORWARD_DECLARE_CLASS(QTableView)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QTextEdit)
|
||||
QT_FORWARD_DECLARE_CLASS(QSqlError)
|
||||
|
||||
class Browser: public QWidget, private Ui::Browser
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Browser(QWidget *parent = nullptr);
|
||||
virtual ~Browser();
|
||||
|
||||
QSqlError addConnection(const QString &driver, const QString &dbName, const QString &host,
|
||||
const QString &user, const QString &passwd, int port = -1);
|
||||
|
||||
void insertRow();
|
||||
void deleteRow();
|
||||
void updateActions();
|
||||
|
||||
public slots:
|
||||
void exec();
|
||||
void showTable(const QString &table);
|
||||
void showMetaData(const QString &table);
|
||||
void addConnection();
|
||||
void currentChanged() { updateActions(); }
|
||||
void about();
|
||||
|
||||
void on_insertRowAction_triggered()
|
||||
{ insertRow(); }
|
||||
void on_deleteRowAction_triggered()
|
||||
{ deleteRow(); }
|
||||
void on_fieldStrategyAction_triggered();
|
||||
void on_rowStrategyAction_triggered();
|
||||
void on_manualStrategyAction_triggered();
|
||||
void on_submitAction_triggered();
|
||||
void on_revertAction_triggered();
|
||||
void on_selectAction_triggered();
|
||||
void on_connectionWidget_tableActivated(const QString &table)
|
||||
{ showTable(table); }
|
||||
void on_connectionWidget_metaDataRequested(const QString &table)
|
||||
{ showMetaData(table); }
|
||||
void on_submitButton_clicked()
|
||||
{
|
||||
exec();
|
||||
sqlEdit->setFocus();
|
||||
}
|
||||
void on_clearButton_clicked()
|
||||
{
|
||||
sqlEdit->clear();
|
||||
sqlEdit->setFocus();
|
||||
}
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &message);
|
||||
};
|
||||
|
||||
class CustomModel: public QSqlTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomModel(QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase())
|
||||
: QSqlTableModel(parent, db) {}
|
||||
|
||||
QVariant data(const QModelIndex &idx, int role) const override
|
||||
{
|
||||
if (role == Qt::BackgroundRole && isDirty(idx))
|
||||
return QBrush(QColor(Qt::yellow));
|
||||
return QSqlTableModel::data(idx, role);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
241
examples/sql/sqlbrowser/browserwidget.ui
Normal file
241
examples/sql/sqlbrowser/browserwidget.ui
Normal file
@ -0,0 +1,241 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Browser</class>
|
||||
<widget class="QWidget" name="Browser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>765</width>
|
||||
<height>515</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Qt SQL Browser</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="ConnectionWidget" name="connectionWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTableView" name="table">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::ActionsContextMenu</enum>
|
||||
</property>
|
||||
<property name="selectionBehavior">
|
||||
<enum>QAbstractItemView::SelectRows</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>180</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>SQL Query</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="sqlEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>18</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>120</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="clearButton">
|
||||
<property name="text">
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="submitButton">
|
||||
<property name="text">
|
||||
<string>&Submit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="insertRowAction">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Insert Row</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Inserts a new Row</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="deleteRowAction">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Delete Row</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Deletes the current Row</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="fieldStrategyAction">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Submit on &Field Change</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Commit on Field Change</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="rowStrategyAction">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Submit on &Row Change</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Commit on Row Change</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="manualStrategyAction">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Submit &Manually</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Commit Manually</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="submitAction">
|
||||
<property name="text">
|
||||
<string>&Submit All</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Submit Changes</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="revertAction">
|
||||
<property name="text">
|
||||
<string>&Revert All</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Revert</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="selectAction">
|
||||
<property name="text">
|
||||
<string>S&elect</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Refresh Data from Database</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>ConnectionWidget</class>
|
||||
<extends>QTreeView</extends>
|
||||
<header>connectionwidget.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>sqlEdit</tabstop>
|
||||
<tabstop>clearButton</tabstop>
|
||||
<tabstop>submitButton</tabstop>
|
||||
<tabstop>connectionWidget</tabstop>
|
||||
<tabstop>table</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
126
examples/sql/sqlbrowser/connectionwidget.cpp
Normal file
126
examples/sql/sqlbrowser/connectionwidget.cpp
Normal file
@ -0,0 +1,126 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "connectionwidget.h"
|
||||
|
||||
#include <QtWidgets>
|
||||
#include <QtSql>
|
||||
|
||||
ConnectionWidget::ConnectionWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||
tree = new QTreeWidget(this);
|
||||
tree->setObjectName(QLatin1String("tree"));
|
||||
tree->setHeaderLabels(QStringList(tr("database")));
|
||||
tree->header()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
QAction *refreshAction = new QAction(tr("Refresh"), tree);
|
||||
metaDataAction = new QAction(tr("Show Schema"), tree);
|
||||
connect(refreshAction, &QAction::triggered, this, &ConnectionWidget::refresh);
|
||||
connect(metaDataAction, &QAction::triggered, this, &ConnectionWidget::showMetaData);
|
||||
tree->addAction(refreshAction);
|
||||
tree->addAction(metaDataAction);
|
||||
tree->setContextMenuPolicy(Qt::ActionsContextMenu);
|
||||
|
||||
layout->addWidget(tree);
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
}
|
||||
|
||||
ConnectionWidget::~ConnectionWidget()
|
||||
{
|
||||
}
|
||||
|
||||
static QString qDBCaption(const QSqlDatabase &db)
|
||||
{
|
||||
QString nm = db.driverName();
|
||||
nm.append(QLatin1Char(':'));
|
||||
if (!db.userName().isEmpty())
|
||||
nm.append(db.userName()).append(QLatin1Char('@'));
|
||||
nm.append(db.databaseName());
|
||||
return nm;
|
||||
}
|
||||
|
||||
void ConnectionWidget::refresh()
|
||||
{
|
||||
tree->clear();
|
||||
QStringList connectionNames = QSqlDatabase::connectionNames();
|
||||
|
||||
bool gotActiveDb = false;
|
||||
for (int i = 0; i < connectionNames.count(); ++i) {
|
||||
QTreeWidgetItem *root = new QTreeWidgetItem(tree);
|
||||
QSqlDatabase db = QSqlDatabase::database(connectionNames.at(i), false);
|
||||
root->setText(0, qDBCaption(db));
|
||||
if (connectionNames.at(i) == activeDb) {
|
||||
gotActiveDb = true;
|
||||
setActive(root);
|
||||
}
|
||||
if (db.isOpen()) {
|
||||
QStringList tables = db.tables();
|
||||
for (int t = 0; t < tables.count(); ++t) {
|
||||
QTreeWidgetItem *table = new QTreeWidgetItem(root);
|
||||
table->setText(0, tables.at(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!gotActiveDb) {
|
||||
activeDb = connectionNames.value(0);
|
||||
setActive(tree->topLevelItem(0));
|
||||
}
|
||||
|
||||
tree->doItemsLayout(); // HACK
|
||||
}
|
||||
|
||||
QSqlDatabase ConnectionWidget::currentDatabase() const
|
||||
{
|
||||
return QSqlDatabase::database(activeDb);
|
||||
}
|
||||
|
||||
static void qSetBold(QTreeWidgetItem *item, bool bold)
|
||||
{
|
||||
QFont font = item->font(0);
|
||||
font.setBold(bold);
|
||||
item->setFont(0, font);
|
||||
}
|
||||
|
||||
void ConnectionWidget::setActive(QTreeWidgetItem *item)
|
||||
{
|
||||
for (int i = 0; i < tree->topLevelItemCount(); ++i) {
|
||||
if (tree->topLevelItem(i)->font(0).bold())
|
||||
qSetBold(tree->topLevelItem(i), false);
|
||||
}
|
||||
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
qSetBold(item, true);
|
||||
activeDb = QSqlDatabase::connectionNames().value(tree->indexOfTopLevelItem(item));
|
||||
}
|
||||
|
||||
void ConnectionWidget::on_tree_itemActivated(QTreeWidgetItem *item, int /* column */)
|
||||
{
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
if (!item->parent()) {
|
||||
setActive(item);
|
||||
} else {
|
||||
setActive(item->parent());
|
||||
emit tableActivated(item->text(0));
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionWidget::showMetaData()
|
||||
{
|
||||
QTreeWidgetItem *cItem = tree->currentItem();
|
||||
if (!cItem || !cItem->parent())
|
||||
return;
|
||||
setActive(cItem->parent());
|
||||
emit metaDataRequested(cItem->text(0));
|
||||
}
|
||||
|
||||
void ConnectionWidget::on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *)
|
||||
{
|
||||
metaDataAction->setEnabled(current && current->parent());
|
||||
}
|
||||
|
41
examples/sql/sqlbrowser/connectionwidget.h
Normal file
41
examples/sql/sqlbrowser/connectionwidget.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef CONNECTIONWIDGET_H
|
||||
#define CONNECTIONWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QTreeWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QTreeWidgetItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QSqlDatabase)
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
|
||||
class ConnectionWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ConnectionWidget(QWidget *parent = nullptr);
|
||||
virtual ~ConnectionWidget();
|
||||
|
||||
QSqlDatabase currentDatabase() const;
|
||||
|
||||
signals:
|
||||
void tableActivated(const QString &table);
|
||||
void metaDataRequested(const QString &tableName);
|
||||
|
||||
public slots:
|
||||
void refresh();
|
||||
void showMetaData();
|
||||
void on_tree_itemActivated(QTreeWidgetItem *item, int column);
|
||||
void on_tree_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
|
||||
private:
|
||||
void setActive(QTreeWidgetItem *);
|
||||
|
||||
QTreeWidget *tree;
|
||||
QAction *metaDataAction;
|
||||
QString activeDb;
|
||||
};
|
||||
|
||||
#endif
|
55
examples/sql/sqlbrowser/main.cpp
Normal file
55
examples/sql/sqlbrowser/main.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "browser.h"
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtWidgets>
|
||||
#include <QtSql>
|
||||
|
||||
void addConnectionsFromCommandline(const QStringList &args, Browser *browser)
|
||||
{
|
||||
for (int i = 1; i < args.count(); ++i) {
|
||||
QUrl url(args.at(i), QUrl::TolerantMode);
|
||||
if (!url.isValid()) {
|
||||
qWarning("Invalid URL: %s", qPrintable(args.at(i)));
|
||||
continue;
|
||||
}
|
||||
QSqlError err = browser->addConnection(url.scheme(), url.path().mid(1), url.host(),
|
||||
url.userName(), url.password(), url.port(-1));
|
||||
if (err.type() != QSqlError::NoError)
|
||||
qDebug() << "Unable to open connection:" << err;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QMainWindow mainWin;
|
||||
mainWin.setWindowTitle(QObject::tr("Qt SQL Browser"));
|
||||
|
||||
Browser browser(&mainWin);
|
||||
mainWin.setCentralWidget(&browser);
|
||||
|
||||
QMenu *fileMenu = mainWin.menuBar()->addMenu(QObject::tr("&File"));
|
||||
fileMenu->addAction(QObject::tr("Add &Connection..."),
|
||||
[&]() { browser.addConnection(); });
|
||||
fileMenu->addSeparator();
|
||||
fileMenu->addAction(QObject::tr("&Quit"), []() { qApp->quit(); });
|
||||
|
||||
QMenu *helpMenu = mainWin.menuBar()->addMenu(QObject::tr("&Help"));
|
||||
helpMenu->addAction(QObject::tr("About"), [&]() { browser.about(); });
|
||||
helpMenu->addAction(QObject::tr("About Qt"), []() { qApp->aboutQt(); });
|
||||
|
||||
QObject::connect(&browser, &Browser::statusMessage, [&mainWin](const QString &text) {
|
||||
mainWin.statusBar()->showMessage(text);
|
||||
});
|
||||
|
||||
addConnectionsFromCommandline(app.arguments(), &browser);
|
||||
mainWin.show();
|
||||
if (QSqlDatabase::connectionNames().isEmpty())
|
||||
QMetaObject::invokeMethod(&browser, "addConnection", Qt::QueuedConnection);
|
||||
|
||||
return app.exec();
|
||||
}
|
70
examples/sql/sqlbrowser/qsqlconnectiondialog.cpp
Normal file
70
examples/sql/sqlbrowser/qsqlconnectiondialog.cpp
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "qsqlconnectiondialog.h"
|
||||
#include "ui_qsqlconnectiondialog.h"
|
||||
|
||||
#include <QSqlDatabase>
|
||||
|
||||
QSqlConnectionDialog::QSqlConnectionDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
|
||||
QStringList drivers = QSqlDatabase::drivers();
|
||||
|
||||
if (!drivers.contains("QSQLITE"))
|
||||
ui.dbCheckBox->setEnabled(false);
|
||||
|
||||
ui.comboDriver->addItems(drivers);
|
||||
}
|
||||
|
||||
QSqlConnectionDialog::~QSqlConnectionDialog()
|
||||
{
|
||||
}
|
||||
|
||||
QString QSqlConnectionDialog::driverName() const
|
||||
{
|
||||
return ui.comboDriver->currentText();
|
||||
}
|
||||
|
||||
QString QSqlConnectionDialog::databaseName() const
|
||||
{
|
||||
return ui.editDatabase->text();
|
||||
}
|
||||
|
||||
QString QSqlConnectionDialog::userName() const
|
||||
{
|
||||
return ui.editUsername->text();
|
||||
}
|
||||
|
||||
QString QSqlConnectionDialog::password() const
|
||||
{
|
||||
return ui.editPassword->text();
|
||||
}
|
||||
|
||||
QString QSqlConnectionDialog::hostName() const
|
||||
{
|
||||
return ui.editHostname->text();
|
||||
}
|
||||
|
||||
int QSqlConnectionDialog::port() const
|
||||
{
|
||||
return ui.portSpinBox->value();
|
||||
}
|
||||
|
||||
bool QSqlConnectionDialog::useInMemoryDatabase() const
|
||||
{
|
||||
return ui.dbCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void QSqlConnectionDialog::on_okButton_clicked()
|
||||
{
|
||||
if (ui.comboDriver->currentText().isEmpty()) {
|
||||
QMessageBox::information(this, tr("No database driver selected"),
|
||||
tr("Please select a database driver"));
|
||||
ui.comboDriver->setFocus();
|
||||
} else {
|
||||
accept();
|
||||
}
|
||||
}
|
36
examples/sql/sqlbrowser/qsqlconnectiondialog.h
Normal file
36
examples/sql/sqlbrowser/qsqlconnectiondialog.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#ifndef QSQLCONNECTIONDIALOG_H
|
||||
#define QSQLCONNECTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ui_qsqlconnectiondialog.h"
|
||||
|
||||
class QSqlConnectionDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QSqlConnectionDialog(QWidget *parent = nullptr);
|
||||
~QSqlConnectionDialog();
|
||||
|
||||
QString driverName() const;
|
||||
QString databaseName() const;
|
||||
QString userName() const;
|
||||
QString password() const;
|
||||
QString hostName() const;
|
||||
int port() const;
|
||||
bool useInMemoryDatabase() const;
|
||||
|
||||
private slots:
|
||||
void on_okButton_clicked();
|
||||
void on_cancelButton_clicked() { reject(); }
|
||||
void on_dbCheckBox_clicked() { ui.connGroupBox->setEnabled(!ui.dbCheckBox->isChecked()); }
|
||||
|
||||
private:
|
||||
Ui::QSqlConnectionDialogUi ui;
|
||||
};
|
||||
|
||||
#endif
|
224
examples/sql/sqlbrowser/qsqlconnectiondialog.ui
Normal file
224
examples/sql/sqlbrowser/qsqlconnectiondialog.ui
Normal file
@ -0,0 +1,224 @@
|
||||
<ui version="4.0" >
|
||||
<author></author>
|
||||
<comment></comment>
|
||||
<exportmacro></exportmacro>
|
||||
<class>QSqlConnectionDialogUi</class>
|
||||
<widget class="QDialog" name="QSqlConnectionDialogUi" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>315</width>
|
||||
<height>302</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Connect...</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="connGroupBox" >
|
||||
<property name="title" >
|
||||
<string>Connection settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="comboDriver" />
|
||||
</item>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="textLabel4" >
|
||||
<property name="text" >
|
||||
<string>&Username:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>editUsername</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="textLabel2" >
|
||||
<property name="text" >
|
||||
<string>D&river</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>comboDriver</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="editDatabase" />
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<widget class="QSpinBox" name="portSpinBox" >
|
||||
<property name="specialValueText" >
|
||||
<string>Default</string>
|
||||
</property>
|
||||
<property name="maximum" >
|
||||
<number>65535</number>
|
||||
</property>
|
||||
<property name="minimum" >
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="value" >
|
||||
<number>-1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="textLabel3" >
|
||||
<property name="text" >
|
||||
<string>Database Name:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>editDatabase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<widget class="QLineEdit" name="editPassword" >
|
||||
<property name="echoMode" >
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="editUsername" />
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<widget class="QLineEdit" name="editHostname" />
|
||||
</item>
|
||||
<item row="4" column="0" >
|
||||
<widget class="QLabel" name="textLabel5" >
|
||||
<property name="text" >
|
||||
<string>&Hostname:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>editHostname</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" >
|
||||
<widget class="QLabel" name="textLabel5_2" >
|
||||
<property name="text" >
|
||||
<string>P&ort:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>portSpinBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" >
|
||||
<widget class="QLabel" name="textLabel4_2" >
|
||||
<property name="text" >
|
||||
<string>&Password:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<cstring>editPassword</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="dbCheckBox" >
|
||||
<property name="text" >
|
||||
<string>Us&e predefined in-memory database</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" >
|
||||
<property name="margin" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton" >
|
||||
<property name="text" >
|
||||
<string>&OK</string>
|
||||
</property>
|
||||
<property name="default" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton" >
|
||||
<property name="text" >
|
||||
<string>&Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<pixmapfunction></pixmapfunction>
|
||||
<tabstops>
|
||||
<tabstop>comboDriver</tabstop>
|
||||
<tabstop>editDatabase</tabstop>
|
||||
<tabstop>editUsername</tabstop>
|
||||
<tabstop>editPassword</tabstop>
|
||||
<tabstop>editHostname</tabstop>
|
||||
<tabstop>portSpinBox</tabstop>
|
||||
<tabstop>dbCheckBox</tabstop>
|
||||
<tabstop>okButton</tabstop>
|
||||
<tabstop>cancelButton</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
18
examples/sql/sqlbrowser/sqlbrowser.pro
Normal file
18
examples/sql/sqlbrowser/sqlbrowser.pro
Normal file
@ -0,0 +1,18 @@
|
||||
TEMPLATE = app
|
||||
TARGET = sqlbrowser
|
||||
|
||||
QT += sql widgets
|
||||
requires(qtConfig(tableview))
|
||||
|
||||
HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h
|
||||
SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp
|
||||
|
||||
FORMS = browserwidget.ui qsqlconnectiondialog.ui
|
||||
build_all:!build_pass {
|
||||
CONFIG -= build_all
|
||||
CONFIG += release
|
||||
}
|
||||
|
||||
# install
|
||||
target.path = $$[QT_INSTALL_EXAMPLES]/sql/sqlbrowser
|
||||
INSTALLS += target
|
Reference in New Issue
Block a user