mirror of
https://github.com/andre-wojtowicz/qt-sql-example.git
synced 2024-11-27 15:50:27 +01:00
Minors for linux compatibility;
Updated readme
This commit is contained in:
parent
1c15c1b020
commit
70cba442ea
27
README.md
27
README.md
@ -1,9 +1,32 @@
|
|||||||
# Qt SQL Example
|
# Qt SQL Example
|
||||||
|
|
||||||
An exemplary Qt app that connects to SQL server and displays a table from a database. The program was made for educational purposes.
|
An exemplary [Qt](https://www.qt.io/) app that connects to SQL server and displays a table from a database. The program was made for educational purposes.
|
||||||
|
|
||||||
![](screenshot.png)
|
![](screenshot.png)
|
||||||
|
|
||||||
The program was tested on:
|
The program was tested on:
|
||||||
* client: Windows 10, Qt 5.9.1,
|
* clients: Windows 10 with Qt 5.9.1, Ubuntu 16.04 with Qt 5.5.1,
|
||||||
* servers: MySQL Server 5.5.57, Microsoft SQL Server 2008 R2 SP3.
|
* servers: MySQL Server 5.5.57, Microsoft SQL Server 2008 R2 SP3.
|
||||||
|
|
||||||
|
## Client config
|
||||||
|
|
||||||
|
The program reads `config.ini` on startup. The file must be located in the app working directory.
|
||||||
|
|
||||||
|
## SQL database drivers
|
||||||
|
|
||||||
|
A comprehensive discussion about SQL database drivers can be found in [Qt Documentation](https://doc.qt.io/qt-5/sql-driver.html).
|
||||||
|
|
||||||
|
### Windows 10
|
||||||
|
|
||||||
|
* Both Qt driver plugins should be already bundled with Qt SDK.
|
||||||
|
* System ODBC driver should be already bundled with Windows.
|
||||||
|
* System MySQL driver can be *installed* by placing `libmysql.dll` from [C API for MySQL (mysqlclient)](https://dev.mysql.com/downloads/connector/c/) in the app working directory.
|
||||||
|
|
||||||
|
### Ubuntu 16.04
|
||||||
|
|
||||||
|
Packages with Qt driver plugins and system SQL manager with drivers:
|
||||||
|
|
||||||
|
* MySQL - `libqt5sql5-mysql` `libmysqlclient20`,
|
||||||
|
* MSSQL/ODBC - `libqt5sql5-odbc` `libodbc1` `odbcinst` `unixodbc` `msodbcsql`__*__.
|
||||||
|
|
||||||
|
__*__ How to install `msodbcsql` - [Installing the Microsoft ODBC Driver for SQL Server on Linux and macOS](https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server).
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
VERSION = 1.0
|
VERSION = 1.1
|
||||||
QMAKE_TARGET_DESCRIPTION = "Qt app that displays SQL table; for educational purposes"
|
QMAKE_TARGET_DESCRIPTION = "Qt app that displays SQL table; for educational purposes"
|
||||||
QMAKE_TARGET_COPYRIGHT = "Andrzej Wojtowicz, Adam Mickiewicz University in Poznan"
|
QMAKE_TARGET_COPYRIGHT = "Andrzej Wojtowicz, Adam Mickiewicz University in Poznan"
|
||||||
QMAKE_TARGET_PRODUCT = "Qt SQL Example"
|
QMAKE_TARGET_PRODUCT = "Qt SQL Example"
|
||||||
|
@ -63,7 +63,7 @@ MainWindow::MainWindow(QWidget* parent, DbController* dbc, QThread* dbt) :
|
|||||||
QFileInfo check_file(inifile);
|
QFileInfo check_file(inifile);
|
||||||
if (check_file.exists() && check_file.isFile())
|
if (check_file.exists() && check_file.isFile())
|
||||||
{
|
{
|
||||||
QSettings settings(inifile, QSettings::Format::IniFormat);
|
QSettings settings(inifile, QSettings::IniFormat);
|
||||||
|
|
||||||
QString engine = settings.value("sql/engine", "").toString();
|
QString engine = settings.value("sql/engine", "").toString();
|
||||||
if (engine == "mysql")
|
if (engine == "mysql")
|
||||||
|
@ -87,7 +87,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>73</x>
|
<x>73</x>
|
||||||
<y>22</y>
|
<y>22</y>
|
||||||
<width>47</width>
|
<width>65</width>
|
||||||
<height>13</height>
|
<height>13</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -100,7 +100,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>163</x>
|
<x>163</x>
|
||||||
<y>22</y>
|
<y>22</y>
|
||||||
<width>47</width>
|
<width>65</width>
|
||||||
<height>13</height>
|
<height>13</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -172,7 +172,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>24</y>
|
<y>24</y>
|
||||||
<width>151</width>
|
<width>211</width>
|
||||||
<height>17</height>
|
<height>17</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -194,7 +194,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>114</y>
|
<y>114</y>
|
||||||
<width>141</width>
|
<width>211</width>
|
||||||
<height>17</height>
|
<height>17</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -235,7 +235,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>30</x>
|
<x>30</x>
|
||||||
<y>54</y>
|
<y>54</y>
|
||||||
<width>51</width>
|
<width>61</width>
|
||||||
<height>16</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -256,13 +256,6 @@
|
|||||||
<string>password:</string>
|
<string>password:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<zorder>lineEdit_login</zorder>
|
|
||||||
<zorder>radio_sql_authentication</zorder>
|
|
||||||
<zorder>radio_windows_authentication</zorder>
|
|
||||||
<zorder>lineEdit_password</zorder>
|
|
||||||
<zorder>label</zorder>
|
|
||||||
<zorder>label_2</zorder>
|
|
||||||
<zorder>groupBox_sql_drivers</zorder>
|
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QPushButton" name="button_connect">
|
<widget class="QPushButton" name="button_connect">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -285,7 +278,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>115</y>
|
<y>115</y>
|
||||||
<width>41</width>
|
<width>81</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -329,7 +322,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>database name:</string>
|
<string>database:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
@ -337,7 +330,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>145</y>
|
<y>145</y>
|
||||||
<width>51</width>
|
<width>81</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -369,7 +362,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>85</y>
|
<y>85</y>
|
||||||
<width>41</width>
|
<width>81</width>
|
||||||
<height>21</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -387,7 +380,7 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>For ODBC/MSSQL: "SQL Server" (Windows), "ODBC Driver 13 for SQL Server", "FreeTDS" (unix), etc.</string>
|
<string>For ODBC/MSSQL: "SQL Server" (Windows), "ODBC Driver 13 for SQL Server" (unix), etc.</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -517,6 +510,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>table:</string>
|
<string>table:</string>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user