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

  • SEARCH
  • Home
  • 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 7751015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:26:24+00:00 2026-06-01T11:26:24+00:00

By default, editing an item in a QTable selects all the text within the

  • 0

By default, editing an item in a QTable selects all the text within the cell. I want to avoid that. However, I cannot seem to find where this happens.

I wrote a simple custom Delegate which inherits from QStyledItemDelegate, and returns a custom object which simply inherits from a QLineEdit. In these classes, I tried some combinations of what I thought could do the “trick”, such as disabling QLineEdit::focusInEvent(), specifying the selection of my QLineEdit, but nothing works.

The closest I get is that when I click a cell, I set the selected text I want. But between the moment when the cell is clicked, and the moment when my custom selection is performed, the whole text is selected anyway, which I want to avoid.

Any idea? Thanks,

  • 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-01T11:26:25+00:00Added an answer on June 1, 2026 at 11:26 am

    Coding a custom QLineEdit like this:

    class MyLineEdit : public QLineEdit {
    public:
      MyLineEdit(QWidget*parent=0) : QLineEdit(parent)
      {}
    
      void showEvent(QShowEvent*)
      {
        deselect();
        setSelection(1,2); // should be configurable
      }
    };
    

    and setting it as editor widget, I can double-click the table cell and obtain a line edit with some pre-selected text without any flickering. Anyway, the entire cell becomes selected in the middle of double-clicking, don’t know if this is acceptable for you.

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

Sidebar

Related Questions

I am editing a certain website which before used the port 80 (default) that
When a JTable component is created, cell editing is enabled by default. How can
I have a text field (flash.display.textField) for editing, but the default font does not
Is it normal that the default behavior for code completion when editing Java is
I'm trying to use Jeditable as an inline editing solution. The default behavior (click
By default, Apache 2.0.52 will respond to any HTTP TRACE request that it receives.
I was trying to change my default/main/startup (whatever you call it) activity by editing
I have already changed the default text in 'description' box in the enter_bug.cgi page
By default, makeprg is set to just make . However, I’ve got a lot
In Django's admin, I want disable the links provided on the select item to

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.