Results 1 to 2 of 2

Thread: SQL select and use

  1. #1
    Join Date
    Mar 2014
    Posts
    11
    Thanks
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default SQL select and use

    Hi to all,
    I need a suggest to how design new code to implement an operation.
    Starting from the fact that I'm able to use the querys fora a database using qt, I need a way to manage this data.

    For example with this code:
    Qt Code:
    1. this->model=new QSqlQueryModel();
    2. model->setQuery("SELECT [DispositivoId],[Descrizione] FROM [IfaCOM].[dbo].[Dispositivo];");
    3. ui->tableView->setModel(model);
    To copy to clipboard, switch view to plain text mode 

    I show the dataset present in the table "Dispositivo" in the tableView object.
    Now I want to use the single values contained in the table for my personal porpouses.

    How I can do it?

    Thank you in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: SQL select and use

    You can either get the values from the model, see methods index() and data() (or the data() method of the QModelIndex returned by index()), or you can run the query again usign QSqlQuery and work with its result.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    cecchinoSMI (6th March 2014)

Similar Threads

  1. Select a row from QTreeView
    By vieraci in forum Qt Programming
    Replies: 5
    Last Post: 7th December 2015, 19:44
  2. How to select a tex in QTExtEdit
    By Furkan in forum Newbie
    Replies: 3
    Last Post: 12th September 2010, 18:00
  3. select query with like
    By ag.sitesh in forum Qt Programming
    Replies: 19
    Last Post: 14th April 2008, 05:28
  4. QTableWidget row select
    By nowire75 in forum Newbie
    Replies: 4
    Last Post: 23rd December 2007, 18:59
  5. select a QTreeWidgetItem
    By mattia in forum Newbie
    Replies: 2
    Last Post: 21st December 2007, 11:01

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.