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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
c++ class logger 6 105
HTML/Webpage Editor for Windows 10 20 165
How to make the Angular JS application work in JetBrains WebStorm 11 2 83
Recommendation vb6 to vb.net or others 14 148
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…
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 columnThat will then direct you to their download page.From that page s…
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 new code templates in NetBeans IDE 8.0 for Windows.

770 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