Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using a QTimeEdit in a delegate - WITHOUT having the values re-set to 00:00:00 when the cell is double-clicked

Posted on 2010-08-17
1
998 Views
Last Modified: 2013-11-23
Hello,

I have a QT project with a QTableWidget.  When the form is loaded the QTableWidget is populated with hard-coded values.  These values are all QStrings that denote time values - ie:  "12:34:45", "02:33:15", etc.

When the user double-clicks on a cell in the table, I want the cell to convert itself to a QEditTime box, so that the user's input is limited to valid time values.

This is easy enough - I just use a delegate to create a QTimeEdit editor like so...

QWidget * TimeEditDelegate::createEditor(QWidget * pParent, const QStyleOptionViewItem& option, const QModelIndex& index)
{
     QTimeEdit * timeEdit = new QTimeEdit(pParent);
     timeEdit->setDisplayFormat("HH:mm:ss");
     return timeEdit;
}

The ONLY problem is, when the user double-clicks on one of these table cells - it erases whatever value was already in there, and replaces it with a "00:00:00" value.  I need it to retain the value after it is double-clicked.

Thanks in Advance,
Timj
0
Comment
Question by:tmitch68
1 Comment
 
LVL 7

Accepted Solution

by:
irfan_omair earned 500 total points
ID: 33460250
Did you try openPersistentEditor() ???? This should solve it
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question