Results 1 to 3 of 3

Thread: Qtablewidget example

  1. #1
    Join Date
    Apr 2011
    Posts
    67
    Thanks
    22
    Thanked 5 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Qtablewidget example

    I have designed a ui with a qtablewidget and i now want to write the code for it for populating it with data.

    How will my function look like responsible for populating qtablewidget with data look like?.
    Last edited by thefatladysingsopera; 30th May 2011 at 15:06. Reason: Had written Qtableview intead of Qtablewidget,the question changed completely as a result.

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

    Default Re: Qtableview example

    You need to implement a model and attach it to your view.
    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
    Jul 2011
    Posts
    11
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Symbian S60

    Default Re: Qtablewidget example

    i'm very new to Qt(only been working on it for a couple of weeks now) so i don't guarantee this is the best solution but it works for me:

    ui->tableWidget->setRowCount(5); //just make sure your table has rows for you to populate

    QTableWidgetItem* item= new QTableWidgetItem("whatever text u want");
    ui->tableWidget->setItem(0,1,item); //choose the cell u want for your item

    for icons use:
    QTableWidgetItem* icon = new QTableWidgetItem();
    realEstateIcon->setIcon(QIcon(QPixmap(":/images/RealEstate.png")));
    ui->tableWidget->setItem(0,0,icon);

    you can create a loop that inserts as many as you want by changing the rows and columns in the setItem function

Similar Threads

  1. QTableView and QLineEdit OUTSIDE of QTableView, like Excel
    By JoZCaVaLLo in forum Qt Programming
    Replies: 10
    Last Post: 13th May 2011, 13:20
  2. Replies: 2
    Last Post: 26th November 2009, 04:45
  3. Help QTableView
    By vinny gracindo in forum Newbie
    Replies: 1
    Last Post: 22nd November 2009, 00:44
  4. QTableView
    By jamesjara in forum Newbie
    Replies: 5
    Last Post: 26th June 2009, 06:37
  5. QTableView
    By fpujol in forum Qt Programming
    Replies: 4
    Last Post: 16th January 2007, 08:17

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.