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
989 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to download a folder from remote to local directory with Notepad++? 10 83
C#  WebForms or MVC 4 105
Error E2158 compiling with Delphi XE10 Seattle 2 88
Angular JS Route 3 54
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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

867 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now