Results 1 to 6 of 6

Thread: check whether a row is filled with values in tablewidget and fill values in new row

  1. #1
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default check whether a row is filled with values in tablewidget and fill values in new row

    hi i am trying to get the inputs from 4 line edit widgets and paste it into table-widgets & also able to fill the first row in table .
    can any one help me out how to check whether the first row is filled and if it is filled how to add the data s in the next consecutive rows one by one in table widget

    Any one can suggest me some solutions.


    Thanks in advance

    Qt Code:
    1. void Widget::on_pushButton_Add_clicked()
    2. {
    3.  
    4.  
    5. ui->tableWidget->setItem(0, 0, new QTableWidgetItem(ui->lineEdit_UDPport->text()));
    6. ui->tableWidget->setItem(0, 1, new QTableWidgetItem(ui->lineEdit_DataName->text()));
    7. ui->tableWidget->setItem(0, 2, new QTableWidgetItem(ui->lineEdit_DataAddress->text()));
    8. ui->tableWidget->setItem(0, 3, new QTableWidgetItem(ui->comboBox_DataType->currentText()));
    9. ui->tableWidget->setItem(0, 4, new QTableWidgetItem(ui->lineEdit_DataLength->text()));
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: check whether a row is filled with values in tablewidget and fill values in new r

    Do you start with an empty table or with a table with one empty row?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    kulsekarr (26th November 2014)

  4. #3
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: check whether a row is filled with values in tablewidget and fill values in new r

    Thanks for your reply . by default i have fixed the size for the table with 10 Rows and 5 columns in the UI

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: check whether a row is filled with values in tablewidget and fill values in new r

    Then you need to keep track which row is the next empty one and then use this to call setItem().
    if the next row is == rowCount() then add a new row

    Cheers,
    _

  6. #5
    Join Date
    Dec 2011
    Location
    Bangalore,India
    Posts
    38
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: check whether a row is filled with values in tablewidget and fill values in new r

    hi thanks, the code which i have pasted in the first thread will copy the contents from different line edits(inputs) after clicking the push button it copies and paste it in the first row of the table widget.
    and when i try to give the input in different line edit boxes once again it must be pasted in the second row of the table widget. it is not happening. please do help me out

    the size of the table widget is fixed in the UI form as 10 rows and 5 columns

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: check whether a row is filled with values in tablewidget and fill values in new r

    Well, your current code specifies row 0, you obviously need to make that a variable that you increase when you've added a row.

    Cheers,
    _

  8. The following user says thank you to anda_skoa for this useful post:

    kulsekarr (27th November 2014)

Similar Threads

  1. Min Max values
    By mqt in forum Qwt
    Replies: 1
    Last Post: 30th August 2013, 01:50
  2. How to convert string hex values to its real binary values?
    By AttilaPethe in forum Qt Programming
    Replies: 1
    Last Post: 20th February 2012, 23:47
  3. passing values in qml
    By vinayaka in forum Newbie
    Replies: 0
    Last Post: 20th July 2011, 14:36
  4. How to set values in QByteArray?
    By Gokulnathvc in forum Newbie
    Replies: 2
    Last Post: 19th July 2011, 07:44
  5. fill cells in a tableWidget
    By edgar in forum Qt Programming
    Replies: 1
    Last Post: 27th August 2009, 19:55

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.