[SOLVED] QDate dateChanged() signal wont let me finished editing
-
wrote on 8 Dec 2010, 08:27 last edited by
hi,
i need to edit a date in my QTableWidget. when i double click the QTableWidget cell, QDateEdit widget will appear in the QTableWidget cell with its date according to the date on the QTableWidget cell before. when i am still selecting the date in the QDateEdit, the dateChanged() signal is emitted without letting me finished my edit.
any great ideas on how to go around this kind of problem?
thanx..
-
wrote on 8 Dec 2010, 08:30 last edited by
You can write your own delegate change that. But that's interesting, the dateChanged() signal closes the edit, did I understand right? so you are editing the parts of the date step by step?
-
wrote on 8 Dec 2010, 08:37 last edited by
yeah, it will close. and yes,kinda like editing step-by-step. let us say the current date is january 1 2010, when i change the month by clicking the up arrow on the right side of the widget, it will automatically close then the new date will appear as february 1 2010. and so with the days and years...
i dont have any ideas on how to implement this by waiting for me to finish it...
-
wrote on 8 Dec 2010, 09:11 last edited by
If you create an delegate, you can overwrite some methods of the base implementation, but to do that, first have a look at QStyledItemdelegate / QItemDelegate and check, how it is done there.
-
wrote on 8 Dec 2010, 09:41 last edited by
thanx.. i alrady started it..
-
wrote on 8 Dec 2010, 11:35 last edited by
There is no such behavior if you do not set an item delegate. Qt uses "QStyledItemDelegate":http://doc.trolltech.com/latest/qstyleditemdelegate.html as a default. The date edit is only ended when you click on another cell oder press the return key.
This looks as if you use your own item delegate, that intercepts the edit/commit mechanism provided by Qt.
This short sample demonstrates the default behavior:
@
#include <QApplication>
#include <QTableWidget>
#include <QDate>int main(int argc, char **argv)
{
QApplication a(argc, argv);QTableWidget tw; tw.setRowCount(5); tw.setColumnCount(3); QTableWidgetItem *twi = new QTableWidgetItem; twi->setData(Qt::EditRole, QDate::currentDate()); tw.setItem(0, 0, twi); tw.show(); return a.exec();
}
@ -
wrote on 9 Dec 2010, 03:08 last edited by
thanx to all your reply coz i now know about item delegate but there is someone in the other forum suggested about editingFinished() signal which works. never see editingFinished() signal in the docs.
none in the QDate, QDateEdit, QDateTime, QDateTimeEdit, QTime & QTimeEdit... -
wrote on 9 Dec 2010, 10:35 last edited by
editingFinished() is a signal of
"QAbstractSpinBox":http://doc.qt.nokia.com/latest/qabstractspinbox.html#editingFinished (which is inherited by "QDateTimeEdit":http://doc.qt.nokia.com/latest/qdatetimeedit.html)
and of "QLineEdit":http://doc.qt.nokia.comlatest/latest/qlineedit.html#editingFinished"QDate":http://doc.qt.nokia.com/latest/qdate.html, "QDateTime":http://doc.qt.nokia.com/latest/qdatetime.html and "QTime":http://doc.qt.nokia.com/latest/qtime.html are not QObjects and therefore send no signals at all.
Signal editingFinished() is not used in QStyledItemDelegate to determine if one is done with editing an item in the view.
Why do you set a customized item delegate at all and which standard behavior do you overwrite?
-
wrote on 9 Dec 2010, 13:34 last edited by
[quote author="xeroblast" date="1291864099"]someone in the other forum suggested about editingFinished() signal which works.[/quote]That would have been me. It would be nice if you place a link in the QtCentre forum thread to this thread as well.
-
wrote on 10 Dec 2010, 02:15 last edited by
[quote author="Franzk" date="1291901696"]That would have been me. It would be nice if you place a link in the QtCentre forum thread to this thread as well.[/quote]
thanx.. http://www.qtcentre.org/threads/36765-QDate-dateChanged()-signal
1/10