Results 1 to 15 of 15

Thread: How to make QListWidget items editable?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Location
    India
    Posts
    162
    Thanks
    20
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question How to make QListWidget items editable?

    I am using Qt 4.3.4. I have created a list widget having some items. I want the items to be editable so that user can modify the contents of the list widget dynamically by double clicking on the list widget item.

    Here's what i am doing:

    Qt Code:
    1. connect (sampleList, SIGNAL (itemDoubleClicked (QListWidgetItem *)), this, SLOT (test (QListWidgetItem *)));
    2.  
    3. void test (QListWidget *item)
    4. {
    5. sampleList->editItem (item);
    6. }
    To copy to clipboard, switch view to plain text mode 

    While creating the list widget items, i am setting the item flags as:

    Qt Code:
    1. item->setFlags (item->flags () & Qt::ItemIsEditable);
    To copy to clipboard, switch view to plain text mode 


    Now, when i run my application, and double click on the list widget item to edit, i get the following error on the terminal:

    "edit: editing failed"
    Now, my query is that how can i make the list widget items editable? I tried modifying the test () function given above as:

    Qt Code:
    1. void test (QListWidget *item)
    2. {
    3. sampleList->openPersistentEditor (item);
    4. }
    To copy to clipboard, switch view to plain text mode 

    Using this code, i am able to edit the item but i am not sure if this is the correct way of doing it. Also, i am not sure about the usage of openPersistentEditor ().
    Last edited by montylee; 29th September 2008 at 10:51.

Similar Threads

  1. Replies: 1
    Last Post: 5th September 2008, 23:54
  2. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57
  3. Get Visible Items from the QListWidget
    By srj in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:13
  4. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  5. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.