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. [SOLVED]SQL header

[SOLVED]SQL header

Scheduled Pinned Locked Moved General and Desktop
sqlmysqlheaderfileconnection
4 Posts 2 Posters 1.6k 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.
  • G Offline
    G Offline
    Gillou_beginqt
    wrote on last edited by Gillou_beginqt
    #1

    Hi I am beginning in Gui programming using QT.I am work in project where a database is needed. I created the database, I know how to make a connection with MYSQL database. But my problem is that I'll my database for different widget and I can't make a connection to the database every time I want to use it. How can I create an header file where I can include to any of my different windows in a my project

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Unless you are disconnecting from your database after each use, you don't need to redo the connection. If you check the related examples in Qt's documentation, you'll see that the connection is generally created in the main function. The QtSql related classes use the default connection unless told otherwise so you don't have to redo it each time unless it's by design.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • G Offline
        G Offline
        Gillou_beginqt
        wrote on last edited by
        #3

        Thank you. I checked those different example and it is working now

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You're welcome !

          Since you have it working now please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          Also, consider up-voting answer(s) that helps you in any thread, they will make it more easy to find for other users :)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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