<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qsqlrelationaltablemodel.cpp --> <title>QSqlRelation Class | Qt SQL 5.9</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.9</td><td ><a href="qtsql-index.html">Qt SQL</a></td><td ><a href="qtsql-module.html">C++ Classes</a></td><td >QSqlRelation</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.9.4 Reference Documentation</td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">QSqlRelation Class</h1> <!-- $$$QSqlRelation-brief --> <p>The <a href="qsqlrelation.html">QSqlRelation</a> class stores information about an SQL foreign key. <a href="#details">More...</a></p> <!-- @@@QSqlRelation --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> <span class="preprocessor">#include <QSqlRelation></span> </td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += sql</td></tr></table></div><ul> <li><a href="qsqlrelation-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2 id="public-functions">Public Functions</h2> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#QSqlRelation">QSqlRelation</a></b>()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#QSqlRelation-1">QSqlRelation</a></b>(const QString &<i>tableName</i>, const QString &<i>indexColumn</i>, const QString &<i>displayColumn</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#displayColumn">displayColumn</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#indexColumn">indexColumn</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#isValid">isValid</a></b>() const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#swap">swap</a></b>(QSqlRelation &<i>other</i>)</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qsqlrelation.html#tableName">tableName</a></b>() const</td></tr> </table></div> <a name="details"></a> <!-- $$$QSqlRelation-description --> <div class="descr"> <h2 id="details">Detailed Description</h2> <p>The <a href="qsqlrelation.html">QSqlRelation</a> class stores information about an SQL foreign key.</p> <p><a href="qsqlrelation.html">QSqlRelation</a> is a helper class for <a href="qsqlrelationaltablemodel.html">QSqlRelationalTableModel</a>. See <a href="qsqlrelationaltablemodel.html#setRelation">QSqlRelationalTableModel::setRelation</a>() and <a href="qsqlrelationaltablemodel.html#relation">QSqlRelationalTableModel::relation</a>() for details.</p> </div> <p><b>See also </b><a href="qsqlrelationaltablemodel.html">QSqlRelationalTableModel</a>, <a href="qsqlrelationaldelegate.html">QSqlRelationalDelegate</a>, and <a href="qtsql-relationaltablemodel-example.html">Relational Table Model Example</a>.</p> <!-- @@@QSqlRelation --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$QSqlRelation[overload1]$$$QSqlRelation --> <h3 class="fn" id="QSqlRelation"><a name="QSqlRelation"></a>QSqlRelation::<span class="name">QSqlRelation</span>()</h3> <p>Constructs an invalid <a href="qsqlrelation.html">QSqlRelation</a> object.</p> <p>For such an object, the <a href="qsqlrelation.html#tableName">tableName</a>(), <a href="qsqlrelation.html#indexColumn">indexColumn</a>(), and <a href="qsqlrelation.html#displayColumn">displayColumn</a>() functions return an empty string.</p> <p><b>See also </b><a href="qsqlrelation.html#isValid">isValid</a>().</p> <!-- @@@QSqlRelation --> <!-- $$$QSqlRelation$$$QSqlRelationconstQString&constQString&constQString& --> <h3 class="fn" id="QSqlRelation-1"><a name="QSqlRelation-1"></a>QSqlRelation::<span class="name">QSqlRelation</span>(const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>tableName</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>indexColumn</i>, const <span class="type"><a href="../qtcore/qstring.html">QString</a></span> &<i>displayColumn</i>)</h3> <p>Constructs a <a href="qsqlrelation.html">QSqlRelation</a> object, where <i>tableName</i> is the SQL table name to which a foreign key refers, <i>indexColumn</i> is the foreign key, and <i>displayColumn</i> is the field that should be presented to the user.</p> <p><b>See also </b><a href="qsqlrelation.html#tableName">tableName</a>(), <a href="qsqlrelation.html#indexColumn">indexColumn</a>(), and <a href="qsqlrelation.html#displayColumn">displayColumn</a>().</p> <!-- @@@QSqlRelation --> <!-- $$$displayColumn[overload1]$$$displayColumn --> <h3 class="fn" id="displayColumn"><a name="displayColumn"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSqlRelation::<span class="name">displayColumn</span>() const</h3> <p>Returns the column from table <a href="qsqlrelation.html#tableName">tableName</a>() that should be presented to the user instead of a foreign key.</p> <!-- @@@displayColumn --> <!-- $$$indexColumn[overload1]$$$indexColumn --> <h3 class="fn" id="indexColumn"><a name="indexColumn"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSqlRelation::<span class="name">indexColumn</span>() const</h3> <p>Returns the index column from table <a href="qsqlrelation.html#tableName">tableName</a>() to which a foreign key refers.</p> <!-- @@@indexColumn --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QSqlRelation::<span class="name">isValid</span>() const</h3> <p>Returns <code>true</code> if the <a href="qsqlrelation.html">QSqlRelation</a> object is valid; otherwise returns <code>false</code>.</p> <!-- @@@isValid --> <!-- $$$swap[overload1]$$$swapQSqlRelation& --> <h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QSqlRelation::<span class="name">swap</span>(<span class="type"><a href="qsqlrelation.html#QSqlRelation">QSqlRelation</a></span> &<i>other</i>)</h3> <!-- @@@swap --> <!-- $$$tableName[overload1]$$$tableName --> <h3 class="fn" id="tableName"><a name="tableName"></a><span class="type"><a href="../qtcore/qstring.html">QString</a></span> QSqlRelation::<span class="name">tableName</span>() const</h3> <p>Returns the name of the table to which a foreign key refers.</p> <!-- @@@tableName --> </div> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>