Results 1 to 6 of 6

Thread: How to read values from QDateEdit placed in QTableWidget

  1. #1
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Platforms
    Windows

    Exclamation How to read values from QDateEdit placed in QTableWidget

    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

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to read values from QDateEdit placed in QTableWidget

    DateEdit Widget is based on QDateTime class which has a toString method (it returns a QString)

  3. #3
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Platforms
    Windows

    Default Re: How to read values from QDateEdit placed in QTableWidget

    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

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to read values from QDateEdit placed in QTableWidget

    I don't know python at all:
    But i guess (no guarantee) the code should look something like:
    Qt Code:
    1. //assuming that date_applfrm is the QDateEdit object
    2. b = self.date_applfrm.dateTime().toString("dd MMM YYYY hh:mm")
    To copy to clipboard, switch view to plain text mode 
    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:
    Qt Code:
    1. QString time = dateEditObject->dateTime().toString("dd MMM YYYY hh:mm");
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Jan 2011
    Posts
    23
    Qt products
    Platforms
    Windows

    Default Re: How to read values from QDateEdit placed in QTableWidget

    i tried this but its not working its giving same error AttributeError : date_applfrm

  6. #6
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to read values from QDateEdit placed in QTableWidget

    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

Similar Threads

  1. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2008, 00:29
  2. How to read and get the values out of the xml?
    By dark1988 in forum Qt Programming
    Replies: 6
    Last Post: 15th July 2008, 08:41
  3. QTableWidget + QDateEdit + Delegates
    By Cykus in forum Newbie
    Replies: 1
    Last Post: 8th June 2008, 00:43
  4. QDateEdit read-only with calendar not r.o.
    By lauranger in forum Qt Programming
    Replies: 2
    Last Post: 24th January 2007, 17:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.