×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    115

    Insert new columns in a QTableWidget at any index

    I can't insert new columns in a QTableWidget at any index!
    I tried with insertColumn() and setColumnCount() but the columns was inserted at the begin of the table.

    Regards
    A993

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: Insert new columns in a QTableWidget at any index

    Hi,

    I tested this and it works fine for me. Column is inserted at the mentioned index -

    filesTable = new QTableWidget(0, 2);
    QStringList labels;
    labels << tr("File Name") << tr("Size");
    filesTable->setHorizontalHeaderLabels(labels);
    filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
    filesTable->verticalHeader()->hide();

    filesTable->insertColumn(1); // Inserts a column in the middle of the earlier 2 columns ('File Name' and 'Size')
    filesTable->setShowGrid(false);
    setCentralWidget(filesTable);

    Are you giving the index in insertColumn(), it should start from 0 (for the first column).. and so on..

Similar Threads

  1. Moving rows in QTableWidget
    By nickich in forum Qt
    Replies: 0
    Last Post: 2011-02-23, 22:54
  2. Get rid of cell cursor in QTableWidget
    By syedzia5 in forum Qt
    Replies: 0
    Last Post: 2010-07-08, 13:03
  3. Replies: 7
    Last Post: 2010-04-16, 12:43
  4. Replies: 3
    Last Post: 2008-04-23, 18:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×