Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QDate dateChanged() signal wont let me finished editing

[SOLVED] QDate dateChanged() signal wont let me finished editing

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 8.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xeroblast
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      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?

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xeroblast
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          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.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • X Offline
            X Offline
            xeroblast
            wrote on last edited by
            #5

            thanx.. i alrady started it..

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              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&#40;&#41;;
              

              }
              @

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • X Offline
                X Offline
                xeroblast
                wrote on last edited by
                #7

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

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  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?

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #9

                    [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.

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • X Offline
                      X Offline
                      xeroblast
                      wrote on last edited by
                      #10

                      [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 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved