Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem in QListWidget item's renaming after executing a message box...
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    M_31
    wrote on last edited by
    #1

    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..

    1 Reply Last reply
    0
    • O Offline
      O Offline
      octal
      wrote on last edited by
      #2

      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 ?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        M_31
        wrote on last edited by
        #3

        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 );
        }
        @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved