[Qt-interest] table values are not shown in database.
Someone
Someone at gmail.com
Sun Jun 26 17:03:21 CEST 2011
I suggest you to study the examples from the Qt sources
(qt/examples/sql). You can find the answer there :)
Kind Regards
Paweł
--
On Sat, Jun 25, 2011 at 7:32 PM, Sujan Dasmahapatra
<sujan.dasmahapatra at gmail.com> wrote:
> Hi Pawel I am trying to create a table but with this I am not able to see
> the headers in the table. A blank table is popping out. Please help me
> someone I am new in SQL programming. Thanks sujan
> QSqlTableModel *model = new
> QSqlTableModel(this,treeview->mainwindow->db);
>
> model->setTable("student");
>
> model->select();
>
> model->setHeaderData(0, Qt::Horizontal, tr("studentID"));
>
> model->setHeaderData(1, Qt::Horizontal, tr("Name"));
>
> model->setHeaderData(2, Qt::Horizontal, tr("FirstName"));
>
> if(model->submitAll())
>
> model->database().commit();
>
> QTableView *view = new QTableView;
>
> view->setModel(model);
>
> view->show();
>
>
> On Sat, Jun 25, 2011 at 9:51 AM, Sujan Dasmahapatra
> <sujan.dasmahapatra at gmail.com> wrote:
>>
>> Dear Pawel
>> Thanks so much. Its working with select... Thanks sujan
>>
>> On Sat, Jun 25, 2011 at 9:03 AM, Someone
>> <Someone at gmail.com> wrote:
>>>
>>> According to the qt documentation setTable method does not select data
>>> from the table so you need to use select() after setTable.
>>>
>>> Kind Regards,
>>> Pawel
>>>
>>> On Sat, Jun 25, 2011 at 4:27 PM, Sujan Dasmahapatra
>>> <sujan.dasmahapatra at gmail.com> wrote:
>>> > QSqlTableModel *model = new QSqlTableModel(this, db); // db is the
>>> > database
>>> > successfully opened.
>>> >
>>> > model->setTable("things");
>>> >
>>> > QTableView *view = new QTableView;
>>> >
>>> > view->setModel(model);
>>> >
>>> > view->show();
>>> > With this pice of code I can only see the header names of the table but
>>> > down
>>> > there some values are not seen like this only book and qty but there
>>> > are
>>> > some 3 values are there i cannot see them. PLease give me some
>>> > suggestions.
>>> >
>>> > Book qty
>>> >
>>> >
>>> > --
>>> > Thanks & Regards
>>> > Sujan Dasmahapatra
>>> > B.E. (Aeronautics)
>>> > Bangalore, India
>>> > Ph:91-9900839788
>>> > mail id : sujan.dasmahapatra at gmail.com
>>> > yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
>>> > icq # 556023244
>>> > skype:sujan.dasmahapatra at skyepe.com
>>> > msn: sujan.dasmahapatra at hotmail.com
>>> >
>>> > _______________________________________________
>>> > Qt-interest mailing list
>>> > Qt-interest at qt.nokia.com
>>> > http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>>> >
>>> >
>>
>>
>>
>> --
>> Thanks & Regards
>> Sujan Dasmahapatra
>> B.E. (Aeronautics)
>> Bangalore, India
>> Ph:91-9900839788
>> mail id : sujan.dasmahapatra at gmail.com
>> yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
>> icq # 556023244
>> skype:sujan.dasmahapatra at skyepe.com
>> msn: sujan.dasmahapatra at hotmail.com
>
>
>
> --
> Thanks & Regards
> Sujan Dasmahapatra
> B.E. (Aeronautics)
> Bangalore, India
> Ph:91-9900839788
> mail id : sujan.dasmahapatra at gmail.com
> yahoo msn : dasmahapatra.aerodynamics at yahoo.co.in
> icq # 556023244
> skype:sujan.dasmahapatra at skyepe.com
> msn: sujan.dasmahapatra at hotmail.com
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
>
>
More information about the Qt-interest-old
mailing list