[Qt-interest] QDate compare
Francesc Vila Garcia
francesc.vila at imb-cnm.csic.es
Fri Apr 29 15:07:16 CEST 2011
If I make a guess from the name, ui.fromDateEdit and ui.toDateEdit are QLineEdit classes, aren't they? And it appears that the GUI is done using QtDesigner, so the two members are pointers. You cannot compare a QLineEdit with a QDate object. You should convert the text (ui.fromDateEdit->text()) to a QDate and then compare the two objects. QDate has a static fromString method, you should take a look.
It also can be that the widgets are QDateEdit or QDateTimeEdit. Both widgets have a date() function that returns a QDate object that you can compare.
But it is difficult without some code to look at.
Just my 2 cents.
Francesc
On 04/29/2011 02:33 PM, Robert Wood wrote:
> I'm struggling to do something really basic with comparing QDates. I
> just don't understand the documentation, so hope someone can help me!
>
> I have an array of structures, with one of the structure members being
> QDate as below:
>
> struct TransactionStructure
> {
> quint8 user;
> QDate transactionDate;
> QTime transactionTime;
> quint8 drawers;
> };
>
> struct TransactionStructure Transactions[2048];
>
> I have two QDateEdit objects on the ui which the user sets.
>
> I assumed I would be able to do this:
>
> if ((Transactions[i].transactionDate> ui.fromDateEdit)&&
> (Transactions[i].transactionDate< ui.toDateEdit))
>
> But this gives an error. The help goes on about operators such as this:
>
> QDate::operator> ( const QDate& d ) const
>
> I am guessing I need to use this kind of thing, but I just cannot work
> out how to use these operators. Google brings up zillions of hits, but
> they all just repeat the documentation and I can't find a simple example
> of how you actually use this in code.
>
> Would be most grateful if someone could demonstrate how to solve this! :~)
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list