Problem in QListWidget item's renaming after executing a message box...



  • i have to set my QListWidget item's as editable like..
    @
    // this slot will execute when i press 'edit' from context menu Edit option
    void testDlg::editList()
    {
    QListWidgetItem *item = ui->listWidget->currentItem();
    item->setFlags( item->flags() | Qt::ItemIsEditable );

    ui->listWidget->editItem( item );
    

    }

    @

    after editing the item , i will do a check , if the item is already present or not
    If YES then i will throw a message like

    @
    QMessageBox msg;
    msg.setText(QString("Name already exists in this group!!"));
    msg.exec();
    emit editgroup(); // the corresponding SLOT is editlist()
    @

    After this message , my focus is still in edited item, but its not showing the corresponding item as editable..



  • I'm not sure to understand what's your issue (maybe someone else will !).

    So, could you explain a little bit more and post a more complete snippet of code ?



  • I have QListWidget with 4 items inside.

    e.g.,
    group1
    group2
    group3
    group4

    I can edit these items by pressing F2 button from the keyboard by placing the cursor on anyone of these items

    let say , if i try to change the 4th item from "group4" to "group1".
    My application will throw some error like

    "Name 'group1' already exist in this list"
    @
    //i am getting the message using the following code
    QMessageBox msg;
    msg.setText(QString("Name").append(strName).append(" already exists in this list"));
    msg.exec();
    emit editgroup(); // the corresponding SLOT is editlist()
    @
    after throwing this error message , i want to have the same item as editable as i had before ..like when i press the F2 button from the keyboard....BUT ITS NOT OCCURING... :-(
    Even i am calling the SLOT editlist from the SIGNAL editgroup() ..after getting this messagebox
    @
    connect( this, SIGNAL(editgroup()), this SLOT(editlist());
    @

    @
    // this is the slot function.
    void testDlg::editList()
    {
    QListWidgetItem *item = ui->listWidget->currentItem();
    item->setFlags( item->flags() | Qt::ItemIsEditable );
    ui->listWidget->editItem( item );
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.