[Qt-interest] QDate compare
Bo Thorsen
bo at fioniasoftware.dk
Fri Apr 29 15:08:42 CEST 2011
Den 29-04-2011 14:33, Robert Wood skrev:
> 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! :~)
Without the code, it's pretty hard to give any help.
Only guess from this is that if ui.fromDateEdit is the dateEdit, you
have to call ui.fromDateEdit->date(). Otherwise, you're comparing with
the pointer to the edit widget.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Qt-interest-old
mailing list