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
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.
Thank you. I checked those different example and it is working now
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 :)