Reputation: 4480
I have this in my header file:
explicit AccessSchedule(QWidget *parent = 0,QString item = "",QTime timefrom )
How should timefrom
be initialized?
Thanks.
Upvotes: 1
Views: 1662
Reputation: 13130
Your function arguments are in wrong order. Arguments with default value should be ALWAYS at the end of argument list. Read this: http://www.learncpp.com/cpp-tutorial/77-default-parameters/
Upvotes: 0
Reputation: 6819
Have you ever considered using QTime::currentTime() as your default parameter ? i.e
explicit AccessSchedule(QWidget *parent = 0,QString item = "",QTime timefrom=QTime::currentTime() )
This way you don't have to check if the object isValid() or isNull() which I think makes code more readable. But it is your call of course.
Upvotes: 2
Reputation: 206679
If you want a default time, you can write:
explicit AccessSchedule(QWidget *parent = 0,QString item = "", QTime timefrom = QTime(11, 45));
timefrom
will represent 11:45. If you just put:
..., QTime timefrom = QTime());
timefrom
will be a "null" time object, i.e. it's isNull()
method will return true and isValid()
will return false.
Upvotes: 1