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. Searching for a QtableView editFinished like Signal
Forum Updated to NodeBB v4.3 + New Features

Searching for a QtableView editFinished like Signal

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 541 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.
  • L Offline
    L Offline
    Laurent Schall
    wrote on last edited by
    #1

    I do have a sheet containing QTableView that is representing the content of a QAbstractTableModel.
    I would like to provide a Save Button on the sheet that should be getting activated when the edited content of the QTableView has changed rather then when the data provided by the QAbstractTableModel has changed as my Model is updating some information from time to time that don't need to be changed (Current Time f.e.). So connecting to the model dataChanged signal is actually not an option for me - I would rather like to connect to a signal from the QtableView like editFinished... problem is that this signal does not exist.

    Maybe someone knows some alternative way to archive this.

    JonBJ 1 Reply Last reply
    0
    • Fuel 0F Offline
      Fuel 0F Offline
      Fuel 0
      wrote on last edited by
      #2

      It could be an Option to define an own Signal and everytime you doing something you can emit it. You can try to combine dataChanged and your other Functions.

      JonBJ 1 Reply Last reply
      0
      • Fuel 0F Fuel 0

        It could be an Option to define an own Signal and everytime you doing something you can emit it. You can try to combine dataChanged and your other Functions.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #3

        @Fuel-0

        It could be an Option to define an own Signal and everytime you doing something you can emit it.

        I suspect @Laurent-Schall is aware of this. The problem is: how do you (easily) recognise "everytime you doing something [to it]"? That's why he is asking if QTableView has any such signal to help him achieve this...

        1 Reply Last reply
        1
        • L Laurent Schall

          I do have a sheet containing QTableView that is representing the content of a QAbstractTableModel.
          I would like to provide a Save Button on the sheet that should be getting activated when the edited content of the QTableView has changed rather then when the data provided by the QAbstractTableModel has changed as my Model is updating some information from time to time that don't need to be changed (Current Time f.e.). So connecting to the model dataChanged signal is actually not an option for me - I would rather like to connect to a signal from the QtableView like editFinished... problem is that this signal does not exist.

          Maybe someone knows some alternative way to archive this.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @Laurent-Schall
          There are some other people who have asked your question :)
          I don't see a definitive resolution, but you might like to have a read for ideas through:

          • https://stackoverflow.com/questions/16272872/whats-the-editing-finished-signal-of-a-qtableview-item
          • https://stackoverflow.com/a/5310784/489865
          • http://www.qtcentre.org/archive/index.php/t-20342.html
          • http://www.qtcentre.org/archive/index.php/t-39663.html
          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by VRonin
            #5

            User editing a cell is not a task the view does, it's something for the delegate:

            class EditFinishDelegate : public QStyledItemDelegate{
                Q_OBJECT
                Q_DISABLE_COPY(EditFinishDelegate)
            public:
                explicit EditFinishDelegate(QObject *parent =Q_NULLPTR) : QStyledItemDelegate(parent){}
                Q_SIGNAL void editFinished(const QModelIndex &index);
                void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE {
                    QStyledItemDelegate::setModelData(editor,model,index);
                    editFinished(index);
                }
            };
            

            You can use it like:

            EditFinishDelegate* delegate = new EditFinishDelegate(this);
            connect(delegate,&EditFinishDelegate::editFinished,saveButton,std::bind(&QPushButton::setEnabled,saveButton,true));
            tableView->setItemDelegate(delegate);
            

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            2

            • Login

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