Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8899951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:59:02+00:00 2026-06-15T00:59:02+00:00

I’ve been facing a problem for several days now. I’m using a QTableView to

  • 0

I’ve been facing a problem for several days now. I’m using a QTableView to display data from a model. I activated the complete line selection when the user click on a cell, to make the interface user friendly:
self.tableau.selectRow(element.row())

But, when the user presses F2, I would like to edit only the column 1. So, the expected behavior is:

  • if I selected the column 4, this one is not editable
  • if I press F2 when column 4 is selected, the column 1 is edited

But with the complete row selection, F2 can not know which cell is selected. So, I re-implemented the event handler:

def keyPressEvent(self, e):
    """It reimplements event management in this method """

    # TODO: find a way to re-select the cell after editing

    # We get the name of current file
    nom_courant = self.tableau.model().index(self.row_selected, 1).data()
    print(nom_courant)

    if e.key() == QtCore.Qt.Key_F2:

        try:
            # We edit the cell name of the selected line
            #http://stackoverflow.com/questions/8157688/specifying-an-index-in-qtableview-with-pyqt
            self.tableau.edit(self.tableau.model().index(self.row_selected, 1))
        except:
            print("Pas de cell sélectionnée")
            pass

    # It retrieves the new file name. CAN NOT do in the
    # if the model is not updated yet.
    nouveau_nom = self.tableau.model().index(self.row_selected, 1).data()
    print(nouveau_nom)

    # Call the fct renaming only if the name has changed
    if nom_courant != nouveau_nom:
        #liste.renameFile(self.current_video, self.tableau.model().index(self.row_selected, 1).data())
        print("entropie")

The matter now is this line:

self.tableau.edit(self.tableau.model().index(self.row_selected, 1))

I have no way to detect the end of the edition of the QLineEdit generated, and I need it to perform actions on the new content of the cell edited, because nouveau_nom is not updated if no keyboard event occurs.

Do you have an idea about how to get the end edition signal ?

(Please forgive my english, I’m french…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T00:59:03+00:00Added an answer on June 15, 2026 at 12:59 am

    First, you don’t need to actually intercept and change the cell selection to a row selection. You can just set the behavior on the view:

    self.tableau.setSelectionBehavior(self.tableau.SelectRows)
    

    This will automatically select rows.

    When you use a custom QLineEdit widgets in your table, then you need to connect QLineEdit.editingFinished() to whatever handler you want. Most likely you want it to call dataChanged on your model.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have been unable to fix a problem with Java Unicode and encoding. The
I am currently running into a problem where an element is coming back from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.