Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SQLite (Drill Down example)
Forum Updated to NodeBB v4.3 + New Features

SQLite (Drill Down example)

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 188 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Flaming MoeF Offline
    Flaming MoeF Offline
    Flaming Moe
    wrote on last edited by Flaming Moe
    #1

    Aloá,

    i have started off with Databases by consulting the DrillDown example
    and there is something in the connectoin.h and view.cpp I haven´t understood.

    https://doc.qt.io/qt-6/qtsql-drilldown-example.html
    -> code
    https://code.qt.io/cgit/qt/qtbase.git/tree/examples/sql/drilldown?h=6.6
    -> connection.h with creation and connection of database
    https://code.qt.io/cgit/qt/qtbase.git/tree/examples/sql/connection.h?h=6.6

    In the connection.h file - the database is opened "db.open()"
    and when "query.exec("...."); is executed, Query "magically" know "how to write to the database".
    Intuitivly I´d have expected, that on creation of 'query' the instance would need something like a socket, a stream or any reference to the opened db.
    What is the principle, I´m missing? I guess it also has to do with the fact, that createConnection() is static?

    I´m wondering the same for in the view.cpp file in the constructor, where the QSqlRelationalTableModel-instance gets created.

    itemTable = new QSqlRelationalTableModel(this);
    

    A lovely day for a ̶g̶̶u̶̶i̶̶n̶̶n̶̶e̶̶s̶ DUFF^^

    C 1 Reply Last reply
    0
    • Flaming MoeF Flaming Moe

      Aloá,

      i have started off with Databases by consulting the DrillDown example
      and there is something in the connectoin.h and view.cpp I haven´t understood.

      https://doc.qt.io/qt-6/qtsql-drilldown-example.html
      -> code
      https://code.qt.io/cgit/qt/qtbase.git/tree/examples/sql/drilldown?h=6.6
      -> connection.h with creation and connection of database
      https://code.qt.io/cgit/qt/qtbase.git/tree/examples/sql/connection.h?h=6.6

      In the connection.h file - the database is opened "db.open()"
      and when "query.exec("...."); is executed, Query "magically" know "how to write to the database".
      Intuitivly I´d have expected, that on creation of 'query' the instance would need something like a socket, a stream or any reference to the opened db.
      What is the principle, I´m missing? I guess it also has to do with the fact, that createConnection() is static?

      I´m wondering the same for in the view.cpp file in the constructor, where the QSqlRelationalTableModel-instance gets created.

      itemTable = new QSqlRelationalTableModel(this);
      
      C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2

      @Flaming-Moe When you construct a QSqlQuery without any arguments, or with only a query string, then the database argument defaults to an invalid QSqlDatabase object. In this circumstance the query object will be associated with the default database, i.e. the QSqlDatabase object returned by QSqlDatabase::database().

      1 Reply Last reply
      3

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved