Results 1 to 8 of 8

Thread: QTableWidget Bug : can't remove row !

  1. #1
    Join Date
    May 2009
    Posts
    28
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation QTableWidget Bug : can't remove row !

    hello everybody
    i want to remove the selected row in my QTableWidget , i am using :

    pieces->removeRow(pieces->currentIndex().row());

    pieces is the QTableWidget , i have no errors in compilation.
    but when i select a row and click on a button to run the action , my application shutdown
    i tried also removeRow(pieces->currentRow()); and i have the same problem

    the problem is in removeRow() because i tried hideRow() and it was working perfectly

    any idea please

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget Bug : can't remove row !

    can you show some more code

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget Bug : can't remove row !

    I'd guess you are doing it from a slot connected to a signal that emits a QTableWidgetItem as its argument. Is that correct?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    May 2009
    Posts
    28
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    Hello
    thnaks for your responses

    this is my code :

    here , a QPushButton to run the action :

    Qt Code:
    1. void AcheterMed::on_suppMed_clicked()
    2. {
    3. pieces->removeRow(pieces->currentIndex().row());
    4. }
    To copy to clipboard, switch view to plain text mode 

    pieces is my QTableWidget , i add items in with this code :

    Qt Code:
    1. void AcheterMed::on_valider_clicked()
    2. {
    3. item1->setText(numero->text());
    4. item2->setText(libelle->text());
    5. item1->setFlags(Qt::ItemIsEditable);
    6. item2->setFlags(Qt::ItemIsEditable);
    7. int j = pieces->rowCount();
    8. for(int i=0;i<nbrePieces->text().toInt();i++)
    9. {
    10. pieces->insertRow(j + i);
    11. pieces->setItem(j + i,0,item1);
    12. pieces->setItem(j + i,1,item2);
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    and i have no others slots !
    i still have the same problem

    n.b : i want to remove the row selected from pieces , pieces is set to singleselections + selectrows .

    this is all !

    thanks again

    i had also the same problem with clearContents() of my QTableWidget , but i use setRowCount(0) , and it's working
    Last edited by wysota; 15th May 2009 at 17:01. Reason: Posts merged

  5. #5
    Join Date
    May 2009
    Posts
    28
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget Bug : can't remove row !

    hello again !
    whene i debug i have the famous " Segmentation fault "
    my window is made with Designer .

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTableWidget Bug : can't remove row !

    Use the debugger to find out where the crash occurs by printing the backtrace.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2009
    Posts
    28
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTableWidget Bug : can't remove row !

    thanks again ;

    but i changed my plan , i deleted all the QTablewidgets , no i am using table views with models (QStandardItemModel + QTableView = QTableWidget ) ; it's better !

    i have no craches , no problems
    i confirm that the problem was in the QTableWidget (many not only one )
    sometimes it works , and sometimes all functions cause errors (removeRow , clearContents , setRowCount , setItem , item ...)
    and i am not the one , if you look at google you will find a lot of similar problems with this widget !!

    so models are better + fast

    thanks

  8. #8
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableWidget Bug : can't remove row !

    another one bites the dust no doubt it requires a bit extra effort, but using proper Model View classes is always the best..and gives you more inside info..soon you'll be pulling towards delegates..and yes, good decision

Similar Threads

  1. remove node in xml file
    By mattia in forum Newbie
    Replies: 1
    Last Post: 6th March 2008, 13:25
  2. QComboBox in QTableWidget : display troubles.
    By Nyphel in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2007, 23:29
  3. QTableWidget editing question
    By Trasmeister in forum Qt Programming
    Replies: 1
    Last Post: 20th September 2006, 18:46
  4. Replies: 6
    Last Post: 5th March 2006, 21:05
  5. QSettings again ... how to remove array elements
    By Mike in forum Qt Programming
    Replies: 4
    Last Post: 11th January 2006, 08:58

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.