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
986 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
Comment Utility
Did you try openPersistentEditor() ???? This should solve it
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
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 synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

771 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

17 Experts available now in Live!

Get 1:1 Help Now