Important: Please read the Qt Code of Conduct -

[solved]Execute query when window opens.

  • I have a listview that is populated from a database on a separate window than my mainwindow, and the code is placed right under the setupui area so it is populated when opened. (Anyone who could give me the name of that particular area would be good to know)

    Upon creating an open and close function for the database, it cycles open and close until qt shuts it down. How do I query and populate the listview by only opening the window?

  • Lifetime Qt Champion


    "setupui area" ? Are you referring to the constructor code ? The widget itself ?

    Just open the database connection at application startup. From then on you can use it to create models etc. where you need them

    Hope it helps

Log in to reply