[Development] QTime microsecond support

Thiago Macieira thiago.macieira at intel.com
Wed Oct 14 23:14:51 CEST 2015


On Wednesday 14 October 2015 23:10:56 Olivier Goffart wrote:
> On Wednesday 14. October 2015 13:53:03 Thiago Macieira wrote:
> > On Wednesday 14 October 2015 14:22:13 Dustin Mitchell wrote:
> > > Hello,
> > > 
> > > Are there plans to support microseconds in the QTime class? I need to
> > > parse
> > > timestamps from a text file and it has microsecond resolution. If not,
> > > I'd
> > > be willing to implement this feature.
> > 
> > You'll have to wait for Qt 6. It's impossible to add it now.
> 
> Not impossible,  just a bit tricky.

It really is impossible. QTime has one member (an int), no d pointer and it 
has a lot of inline members that access that integer assuming it is a 
millisecond value.

> One could add a Qt::TimerType which is of type "MicroSecondResolutionTimer"
> which would change the meaning of the interval to be in microsecond.
> 
> Then you would need a protected
> QAbstractEventDispatcher::setSupportMicroSecondTimer  that the capable
> dispatcher would set to true.  Qt would have to convert to milisecond if the
> event dispatcher does not support this.

He said QTime, not QTimer.

For microsecond support in QTimer, I'd like to see <chrono> in use. With Qt 
5.7 and QT_HAS_INCLUDE(<chrono>), that should be possible, since any and all 
use of std::chrono is inline anyway.

As for the event dispatcher, please make sure that any solution you develop 
works with user-provided dispatchers that do not know about microsecond 
resolution. This may be an impossible task before Qt 6.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center




More information about the Development mailing list