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. Use QSqlDatabase as the only active session

Use QSqlDatabase as the only active session

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 857 Views 1 Watching
  • 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.
  • F Offline
    F Offline
    fede.pereyra.88
    wrote on last edited by
    #1

    Hi guys,

    I'm a newbie in Qt and my situation is as follows: I'm developing a system with which I need to connect to a database, particularly PostgreSQL.
    I have a home screen that allows log in (connect to the database with a username and password). After the start of session to be successful, i need to interact with information in the database. Obviously, I want to have only one active session database.
    My question is, i can use QSqlDatabase to accomplish this? or i need to implement a singleton as best solution? If i can use the QSqlDatabase, how do you do to manage a single instance in the whole system?

    Best Regards.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      No, you can use QSqlDatabase, and there is no need for a separate singleton implemenation to manage your database. QSqlDatabase already uses (named) connections that you can simply refer to.

      1 Reply Last reply
      0

      • Login

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