Results 1 to 6 of 6

Thread: building a basic grid (urgent)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    59

    Default building a basic grid (urgent)

    Hi everyone!
    I had created a database and in it a table(named USER). Then by giving the command "select * from user" and ui->tableview->setModel(obj), i could display the contents of database in a tableview in form of a grid. But now i want to create a grid manually without using database. All the fields like id,name,address should be entered manually and then the contents displayed in a tableview. Can any one please tell me how to do it, please?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: building a basic grid (urgent)

    You need to have your own model attached to the table view. You may use QStandardItemModel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    59

    Default Re: building a basic grid (urgent)

    Quote Originally Posted by wysota View Post
    You need to have your own model attached to the table view. You may use QStandardItemModel.
    Ok fine. I have to use that class. But how do i insert the field names like ID, NAME, ADDRESS and then the corresponding values for it? So many commands are there, i'm confused to use which one for which?

  4. #4
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    10
    Thanked 31 Times in 25 Posts

    Default Re: building a basic grid (urgent)

    Hi,

    You could also use a QTableWidget. Then you can very easily first define the colums using the editor in Qt Designer. Then in your program you can loop over all your records and add rows to the tablewidget.

    Best regards,
    Marc

  5. #5
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    59

    Default Re: building a basic grid (urgent)

    thanks, but i did it in a slightly different way after seeing the example of "custom sort/filter model".

    With regards,

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: building a basic grid (urgent)

    Quote Originally Posted by sattu View Post
    But how do i insert the field names like ID, NAME, ADDRESS and then the corresponding values for it?
    For the former use QStandardItemModel::setHorizontalHeaderLabels(). For the latter use QStandardItemModel::appendRow()
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qwt Zooming Problem....urgent
    By Raghaw in forum Qwt
    Replies: 0
    Last Post: 2nd September 2009, 16:12
  2. Urgent! help
    By Sheng in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd October 2008, 22:03
  3. [URGENT] Weird compile error [URGENT]
    By MarkoSan in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2008, 00:54
  4. urgent issue qt4.2
    By pratik in forum Qt Programming
    Replies: 2
    Last Post: 4th July 2007, 17:35
  5. Basic: problem building designer application
    By kingslee in forum Qt Tools
    Replies: 2
    Last Post: 31st August 2006, 16:26

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
  •  
Qt is a trademark of The Qt Company.