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. How to keep QListWidget focus policy to Qt::NoFocus after editing an item.
Forum Updated to NodeBB v4.3 + New Features

How to keep QListWidget focus policy to Qt::NoFocus after editing an item.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 7.4k Views 1 Watching
  • 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.
  • B Offline
    B Offline
    Bekos
    wrote on last edited by
    #1

    Hello everyone,

    I am new to Qt Programming, so please forgive me if I am asking something silly :P
    I have a QListWidget with some QListWidgetItems attached. I use QListWidget::setFocusPolity(Qt::NoFocus) in order to disable focus on the list. I also have a button that calls QListWidget::editItem() when I click it. When I click the button the QListWidget regains focus automatically(look like Qt does it internally in order to edit the item). The problem is that I don't know how to unset the focus after editing the item. I tried to connect the signal itemChanged(QListWidgetItem*) to a slot that changes the current focus from QListWidget to my main Window widget but this works only if make changes on the QListWidgetItem. If I click the button but then press Esc without changing the text of the QListWidgetItem then the itemChanged() signal is not emitted. So, my question is the following: Is there some kind of "editingFinished" signal/event emitted after editing a QListWidgetItem?

    Thanks in advance!

    Cheers

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Maybe "QAbstractItemDelegate::closeEditor() ":http://doc.qt.nokia.com/latest/qabstractitemdelegate.html#closeEditor can help you. You can connect it like this:

      @
      connect(
      itemViewOrWidget->itemDelegate(),
      SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)),
      this,
      SLOT(editorWasClosed(QWidget*,QAbstractItemDelegate::EndEditHint))
      );
      @

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Bekos
        wrote on last edited by
        #3

        Thanks mate! It works!
        Although if finish editing an item by clicking another item on the list it won't work. (it only works if i press ENTER , ESC etc) But that's not a problem, in that case I can catch the itemClicked() signal and reset the focus. Thanks for help dude!

        Cheers!

        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