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
1,004 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

717 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