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 integration with Qt Widgets
Forum Updated to NodeBB v4.3 + New Features

SQLite integration with Qt Widgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 393 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.
  • S Offline
    S Offline
    Swati777999
    wrote on 18 Nov 2021, 09:54 last edited by
    #1

    Hi All,

    Hope you're doing well.

    I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.

    Any help will be highly appreciated!

    Thanks.

    “ In order to be irreplaceable, one must always be different” – Coco Chanel

    J P 2 Replies Last reply 18 Nov 2021, 09:59
    0
    • S Swati777999
      18 Nov 2021, 09:54

      Hi All,

      Hope you're doing well.

      I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.

      Any help will be highly appreciated!

      Thanks.

      J Offline
      J Offline
      JonB
      wrote on 18 Nov 2021, 09:59 last edited by
      #2

      @Swati777999
      If you want no more than what console output would show (i.e. some text for the rows & columns) but visible in a widget, just create, say, a QPlainTextEdit (or even just a QLabel) as the central widget and put the textual representation of the result set returned from the query there.

      If you want something a bit "nicer", say a table with rows & columns from the query, then create a QTableView as the central widget and bind it to the SQLite model you are using.

      1 Reply Last reply
      2
      • S Swati777999
        18 Nov 2021, 09:54

        Hi All,

        Hope you're doing well.

        I want to integrate SQLite in one of my Qt projects where the result of SQLite should appear as the central widget of the main window. Is it possible to do so, if yes, how? I just don't simply want to display the solution of my query in Qt Creator's console but I want the output of the SQLite interface should occupy the central Widget of the MainWindow.

        Any help will be highly appreciated!

        Thanks.

        P Online
        P Online
        Pl45m4
        wrote on 18 Nov 2021, 10:44 last edited by
        #3

        @Swati777999

        To extend @JonB answer:

        Depends on what you really want to display and how your data / database looks like.
        If you have a single and more or less simple database table, have a look at QSqlTableModel

        • https://doc.qt.io/qt-5/qsqltablemodel.html#details

        or even QSqlQueryModel, for even more simple, read-only SQL database access queries.

        • https://doc.qt.io/qt-5/qsqlquerymodel.html#details

        For anything further than that, you probably need to write your own database model + view (to change/insert data using your graphical representation of your data).


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        3

        1/3

        18 Nov 2021, 09:54

        • Login

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