PDA

View Full Version : How to read values from QDateEdit placed in QTableWidget



ad3d
10th January 2011, 11:13
I am using QDateEdit & QComboBox in QTableWidget in few columns and trying to read it from QComboBox using

cmb_tlnm = self.leaves_app_table.cellWidget(i,8)
a = self.cmb_tlnm.currentText()

its working fine but if i try to use same process for QDateEdit

date_applfrm = self.leaves_app_table.cellWidget(i,0)
b = self.date_applfrm.date()

i am getting error -
b = self.date_applfrm.date()
AttributeError: date_aaplfrm

can someone tell me how can i read values from this QDateEdit which i have used in QTableWidget

THANX IN ADVANCE

Zlatomir
10th January 2011, 11:29
DateEdit (http://doc.qt.nokia.com/latest/qdateedit.html) Widget is based on QDateTime (http://doc.qt.nokia.com/latest/qdatetime.html) class which has a toString (http://doc.qt.nokia.com/latest/qdatetime.html#toString) method (it returns a QString)

ad3d
10th January 2011, 13:07
i am a totally new to python could you plz tell me what modifications i need to do in above syntax of my piece of code

Zlatomir
10th January 2011, 13:50
I don't know python at all:
But i guess (no guarantee) the code should look something like:

//assuming that date_applfrm is the QDateEdit object
b = self.date_applfrm.dateTime().toString("dd MMM YYYY hh:mm")

I'm telling this to try to help you if my python hack doesn't work (since i don't know python)
In C++ (i assume i python code too) you need to access the dateTime() to return a QDateTime object which has a toString method you need to call with a string parameter (of the format you want see the link to documentation in my previous post)
This is C++ code:

QString time = dateEditObject->dateTime().toString("dd MMM YYYY hh:mm");

ad3d
11th January 2011, 05:34
i tried this but its not working its giving same error AttributeError : date_applfrm

Zlatomir
11th January 2011, 11:52
I don't know python and i'm not sure about what that error means, but it looks like a typo:

b = self.date_applfrm.date()
AttributeError: date_aaplfrm