Results 1 to 2 of 2

Thread: Reconnect problem

  1. #1
    Join Date
    Jul 2006
    Posts
    126
    Thanks
    17
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Reconnect problem

    Hi,

    I have a QTableWidget with QTextBrowser inherit Widgets on its cells. But when I want to delete a Item I can't reconnect the rest of items.

    The code of remove function is the next:
    Qt Code:
    1. void Itinerario::on_eliminarToolButton_clicked(){
    2. desconectarWaypoints();
    3.  
    4. for(int i=0;i<waypoints->rowCount();i++){
    5. WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM));
    6. if(item->selected()){
    7. if(QMessageBox::question(this, "", "Esta seguro de que desea eliminar el Waypoint?",
    8. QMessageBox::Yes, QMessageBox::No)==QMessageBox::Yes){
    9. item->disconnect();
    10. waypoints->removeRow(i);
    11.  
    12. setWindowModified(true);
    13. }
    14.  
    15. return;
    16. }
    17. }
    18. reconectarWaypoints();
    19. }
    To copy to clipboard, switch view to plain text mode 

    The code of remove connections is:
    Qt Code:
    1. void Itinerario::desconectarWaypoints(){
    2. for(int i=0;i<waypoints->rowCount();i++){
    3. WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM));
    4.  
    5. item->disconnect();
    6. }
    7. }
    To copy to clipboard, switch view to plain text mode 

    And the code of reconnect connections finally is:
    Qt Code:
    1. void Itinerario::reconectarWaypoints(){
    2. for(int i=0;i<waypoints->rowCount();i++){
    3. WaypointItem *item=static_cast<WaypointItem*>(waypoints->cellWidget(i, TEXTBROWSER_CELLITEM));
    4.  
    5. connect(item, SIGNAL(clicked(WaypointItem*, int)), SLOT(waypointClicked(WaypointItem*, int)));
    6. connect(item, SIGNAL(doubleClick(WaypointItem*, int)), SLOT(waypointDoubleClicked(WaypointItem*, int)));
    7. connect(item, SIGNAL(modifiedChange(bool)), parent(), SLOT(setWindowModified(bool)));
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    I want to reconnect because if I dont do remove-reconnect the connection of removed item appears to be here.

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Reconnect problem

    Not sure if I understand the problem.

    If you delete an item, the connections that are left are wrong? Therefor you first disconnect them all and create new connections?

    If so, it might be better to simplify and use QSignalMapper.


    btw:
    If I selected 100 items for removal, I get 100 dialogs asking me if I'm sure?
    You might want to ask only once

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.