[Qt-interest] QDate compare

Christian Döring christian.doering at uni-muenster.de
Fri Apr 29 15:06:34 CEST 2011


Hi,

Robert Wood schrieb:
> 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))
>   
I think you just forgot to get the selected date from the dateedit. You
are comparing a date with QDateEdit object.
The following should work:
    if ((Transactions[i].transactionDate > ui.fromDateEdit->date()) &&
        (Transactions[i].transactionDate < ui.toDateEdit->date()))

> 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
>   
Regards
Christian



More information about the Qt-interest-old mailing list