[SOLVED] QDate dateChanged() signal wont let me finished editing
-
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..
-
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...
-
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();
}
@ -
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... -
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?
-
-
[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