Results 1 to 1 of 1

Thread: problem with tableWidget resizeRowsToContents

  1. #1
    Join Date
    Jul 2009
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default problem with tableWidget resizeRowsToContents

    I have a problem with auto resize rows. On a form two QTableWidgets, with 4 columns, and a button. Constructor and button have same code. But result is different. Below is code with problem, with some changes (for example change columns count) it works properly), but i can't understand where is problem...

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7. fillTable(ui->tableWidget);
    8. }
    9.  
    10. void MainWindow::on_pushButton_clicked()
    11. {
    12. fillTable(ui->tableWidget_2);
    13. }
    14.  
    15. void MainWindow::fillTable(QTableWidget *tableWidget)
    16. {
    17.  
    18. tableWidget->setColumnWidth(0,30);
    19. tableWidget->setColumnWidth(1,200);
    20. tableWidget->setColumnWidth(2,50);
    21. tableWidget->setColumnWidth(3,330);
    22.  
    23.  
    24.  
    25. int rownum = tableWidget->rowCount();
    26. tableWidget->setRowCount(tableWidget->rowCount()+1);
    27.  
    28. wi = new QTableWidgetItem("1");
    29. tableWidget->setItem(rownum,0,wi);
    30.  
    31. wi = new QTableWidgetItem("");
    32. wi->setToolTip("");
    33. tableWidget->setItem(rownum,1,wi);
    34.  
    35. QString s= "158";
    36. wi = new QTableWidgetItem(s);
    37. wi->setToolTip(s);
    38. tableWidget->setItem(rownum,2,wi);
    39.  
    40. s= "asdg asdgd agjdj sgjagjsdgj asgdjadg wudi agdu da uidgwgau sdgyugayu gwdyua wd wad awugyd uadyu awydg yw dag dayds asjd ajdajsd sa jdjas djas djasd as"
    41. "retuer uthwuie huirohwuerh wewer asejr jhb rjh ajkrkjhr uiworu howuiroah ruar ioauh iouao ui u uia uui wiuer iawu riuawi ruiawriawu hruiaw "
    42. "aewuh riauwh riuawhi ruhawuirhawuirh uishfj ijsdhf kasjf d kfjashe lelk a7f8 73 8fw378 8wfrwofe bfseb jsbf js bsj sjbf sj fjsb fjsfj sfjs bjbf jsfj s fsj fsj f";
    43. wi = new QTableWidgetItem(s);
    44. wi->setToolTip(s);
    45. tableWidget->setItem(rownum,3,wi);
    46.  
    47. tableWidget->resizeRowsToContents();
    48. }
    To copy to clipboard, switch view to plain text mode 

    ps. sorry for my english
    Last edited by eugenesm; 1st February 2010 at 13:45.

Similar Threads

  1. QTableView - resizeRowsToContents() poor performance
    By antarctic in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2009, 13:13
  2. [B]tableWidget row,col to textEdit[B]
    By briang in forum Newbie
    Replies: 1
    Last Post: 6th November 2009, 04:22
  3. problem with tablewidget..
    By reshma in forum Qt Programming
    Replies: 6
    Last Post: 22nd March 2009, 15:37
  4. again problem in add items in tablewidget
    By jyoti in forum Qt Tools
    Replies: 3
    Last Post: 24th November 2006, 12:03
  5. tablewidget and pixmap
    By magoo in forum Qt Programming
    Replies: 7
    Last Post: 8th November 2006, 21:04

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.