Results 1 to 5 of 5

Thread: My QTableWidget doesn't want to let me add a title to a new row with the button

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2019
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: My QTableWidget doesn't want to let me add a title to a new row with the button

    try using this;

    ui->tableWidget->insertRow(row)

    count starts from 0 because nothing is there, row 0 is actually the index for the first item. every time you press the add button you will get a new line.


    edit: you may also be trying to edit your headers, here is an example of something I am using right now.

    Qt Code:
    1. void Resolver::on_pushButton_6_clicked()
    2. {
    3. ui->calcResults->clear();
    4. ui->calcResults->setColumnCount(5);
    5. m_TableHeader<<"Bet"<<"Balance"<<"Wager"<<"Payout"<<"Profit"; // is a QStringList
    6. ui->calcResults->setHorizontalHeaderLabels(m_TableHeader);
    7.  
    8. ......
    9.  
    10.  
    11. int count = ui->calcResults->rowCount();
    12. ui->calcResults->insertRow(count);
    To copy to clipboard, switch view to plain text mode 

    you will want to setVerticleHeaderLabels instead

    https://doc.qt.io/qt-5/qtablewidget.html
    Last edited by Prodeine; 20th March 2019 at 01:11.

Similar Threads

  1. Force dialog to have WhatsThis title bar button
    By hvengel in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2013, 22:39
  2. Show maximize button in the title bar of a QDialog under GNOME
    By lalesculiviu in forum Qt Programming
    Replies: 1
    Last Post: 25th June 2010, 07:46
  3. How can I add a custom button to a QWidget's title bar
    By JPNaude in forum Qt Programming
    Replies: 4
    Last Post: 22nd February 2010, 10:40
  4. Replies: 5
    Last Post: 21st April 2008, 07:54
  5. No restore button in QDockWidget title bar
    By trskel in forum Qt Programming
    Replies: 1
    Last Post: 21st September 2007, 09:59

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.