Results 1 to 3 of 3

Thread: adding in values to table

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    87
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Unhappy adding in values to table

    hello there, i have created a table using QTableWidget class which is inserted inside a tabWidget. i want to add a character "*" diagonally across all the cells which relate to the same number i.e. stick "*" which relates to (0,0)(1,1) and (2,2) etc because i dont want the user to enter any data in they fields. i tried using addItem( ) with a while loop and a for loop to add in the character but this gave me errors after running the program. is there any quick way to do this without having to use addItem individually for each cell?? heres my code that i tried to use for the table:

    DemandsTab:emandsTab(const QFileInfo &fileInfo, QWidget *parent)
    : QWidget(parent)
    {

    int rows = 0, columns = 0;

    QLabel *testme = new QLabel(tr("Suck it the 4th time"));

    QTableWidget *demands = new QTableWidget(this);

    demands->setRowCount(10);
    demands->setColumnCount(10);

    int row = demands->rowCount();
    int column = demands->columnCount();

    QTableWidgetItem *nodesHeaderItem = new QTableWidgetItem(tr("Cubes"));
    nodesHeaderItem->setTextAlignment(Qt::AlignVCenter);



    QTableWidgetItem *asterix = new QTableWidgetItem(tr("*").arg((row+1)+(column+1)));


    ---------------heres where the problem lies-------

    for(int i=0;i<10;i++)
    {
    demands->setItem(rows, columns, asterix);
    rows++;
    columns++;
    )


    -----------------------------------------------------------
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(testme);
    mainLayout->addWidget(demands);
    mainLayout->addStretch(0);
    setLayout(mainLayout);
    }


    any help would be much appreciated thanks, Jag
    Last edited by therealjag; 8th February 2006 at 23:56.

Similar Threads

  1. Postgresql QSqlRelationalTableModel empty table
    By RolandHughes in forum Qt Programming
    Replies: 0
    Last Post: 12th November 2008, 17:18
  2. Replies: 8
    Last Post: 25th February 2008, 17:00
  3. Inserting Integer Values to table.
    By kenny_isles in forum Newbie
    Replies: 2
    Last Post: 22nd February 2007, 07:17
  4. Updating Table Values.
    By kenny_isles in forum Newbie
    Replies: 14
    Last Post: 13th February 2007, 11:04
  5. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 18:06

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.