Results 1 to 5 of 5

Thread: removing of selected rows

  1. #1
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Thumbs up removing of selected rows

    Hello everyone ........
    I have a problem that I wana remove selected row from Q3Table but whenever i remove it , there remains one selected row.............
    I don't know what mistake I m doing ????
    My code is as following ......
    Qt Code:
    1. void dlgCreateplaylist::pbRemove_clicked()
    2.  
    3. {
    4.  
    5.  
    6.  
    7. int flag=0;
    8.  
    9. numberFrame1=0,numberFrame2=0,numberFrame3=0;
    10.  
    11. pbSelectall2->setText("Select All");
    12.  
    13. int checked[25],index=0;
    14.  
    15.  
    16.  
    17. /******************************************************
    18.  
    19.   *check the row number in table2 is checked or unhecked and remove*********
    20.  
    21. ******************************************************/
    22.  
    23. Q3CheckTableItem *pb1 = new Q3CheckTableItem(Table2, " ");
    24.  
    25. for(int r=0;r<Table2->numRows();r++)
    26.  
    27. {
    28.  
    29. pb1=(Q3CheckTableItem *) Table2->item(r,0);
    30.  
    31. if(pb1->isChecked())
    32.  
    33.  
    34. {
    35.  
    36.  
    37.  
    38. checked[index++]=r;
    39.  
    40.  
    41.  
    42. Table2->removeRow(r);
    43.  
    44.  
    45. qDebug()<<"value of Index"<<index;
    46.  
    47. r=r-1;
    48.  
    49. flag=1;
    50.  
    51. flags=0;
    52.  
    53. }
    54.  
    55.  
    56.  
    57. }
    58.  
    59.  
    60. if(flag==0)
    61.  
    62. {
    63.  
    64. QMessageBox::information( this, "Createplaylist","Select the Media item to Deleted.");
    65.  
    66. }
    To copy to clipboard, switch view to plain text mode 

    Please if anyone can do something I'll apperciate his reply........Thanx in advance
    Last edited by jpn; 9th June 2008 at 08:15. Reason: missing [code] tags

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: removing of selected rows

    It seems that you are creating a new item (which is never used).
    J-P Nurmi

  3. #3
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: removing of selected rows

    As jpn mentions, you add a row to the table whenever pbRemove_clicked() is called.

    this happend at line 23 in the shown code
    you could avoid this by replacing that line with:

    Qt Code:
    1. Q3CheckTableItem *pb1 = 0;
    To copy to clipboard, switch view to plain text mode 
    Last edited by bhs-ittech; 9th June 2008 at 09:28. Reason: meaning twisting parsing corrected

  4. #4
    Join Date
    Jan 2008
    Posts
    72
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Thumbs up Re: removing of selected rows

    Thanx for reply but tht is not solution ...............I just want to remove selected rows nothing else..........
    for this I use Q3checkTableItem to only tht perticuler row is Checked or not.........but What mistake I m doing tht there remains one row...............
    If you can do something please I really need ur help

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: removing of selected rows

    Actually it IS the solution.
    Quote Originally Posted by MrShahi View Post
    Qt Code:
    1. Q3CheckTableItem *pb1 = new Q3CheckTableItem(Table2, " ");
    To copy to clipboard, switch view to plain text mode 
    This will create a NEW item and add it to Table2. According to your problem description this is exactly what you want to avoid.
    J-P Nurmi

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 12:49
  2. iterating selected rows in a qtableview
    By JeanC in forum Qt Programming
    Replies: 2
    Last Post: 19th January 2008, 14:29
  3. Removing rows
    By indifference in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2007, 16:54
  4. Showing selected rows in a separate table
    By dnnc in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2007, 16:35
  5. Get list of selected rows from QTableView
    By jnk5y in forum Qt Programming
    Replies: 8
    Last Post: 17th February 2006, 16:59

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.