Results 1 to 11 of 11

Thread: signal of QListWidget doesn't work

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #6
    Join Date
    Sep 2008
    Location
    Flanders/Belgium
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Re: signal of QListWidget doesn't work

    Quote Originally Posted by montylee View Post
    you can use the following syntax:
    Qt Code:
    1. connect(listWidget, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(enableDeleteButton(QListWidgetItem *)));
    To copy to clipboard, switch view to plain text mode 

    This way, in the enableDeleteButton() function, u can access the current item from the argument.

    An alternate solution is to have the button you want to enable accessible in the enableDeleteButton() function and use currentItem () to get the current item.
    To make the button accesible, declare the button in the class itself (as a private variable), then you'll be able to access it in the enableDeleteButton() function.
    I can't figure it out .. well, I'm new to C++ and Qt

    I changed a few things ...

    Qt Code:
    1. connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(delete_Item(QListWidgetItem*)));
    2.  
    3. void myQtApp::delete_Item(QListWidgetItem* item)
    4. {
    5. QMessageBox msgDelete;
    6. msgDelete.setText("item is going to be removed");
    7. msgDelete.setStandardButtons(QMessageBox::Yes);
    8. int msg=msgDelete.exec();
    9.  
    10. listWidget->removeItemWidget(item);
    11. }
    To copy to clipboard, switch view to plain text mode 

    But the item is not removed ... probably I'm using the wrong code..
    I read that QListWidget is read-only by default, I can't find out if that's true or how to change that if that's the case.

    Don't mind the MessageBox in the function, I still have to implement a second button so I can choose to delete or to leave the item. The delete button I previously used is no longer valid.

    Thanks for your help.
    Last edited by jpn; 30th September 2008 at 16:39. Reason: missing [code] tags
    Vito
    from Flanders/Belgium

Similar Threads

  1. QListWidget SIGNAL Problem
    By skuda in forum Qt Programming
    Replies: 19
    Last Post: 28th October 2009, 14:42
  2. QListWidget clicked signal
    By asieriko in forum Qt Programming
    Replies: 12
    Last Post: 10th August 2007, 15:37
  3. Replies: 3
    Last Post: 15th April 2007, 19:16
  4. Replies: 13
    Last Post: 15th December 2006, 11:52

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.