All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qt.core.QTimer Maven / Gradle / Ivy

package io.qt.core;


/**
 * 

Repetitive and single-shot timers

*

Java wrapper for Qt class QTimer

*/ public class QTimer extends io.qt.core.QObject { /** * This variable stores the meta-object for the class. */ public static final io.qt.core.QMetaObject staticMetaObject = io.qt.core.QMetaObject.forType(QTimer.class); /** *

See QTimer::timeout()

*/ public final PrivateSignal0 timeout = new PrivateSignal0(); /** *

Overloaded constructor for {@link #QTimer(io.qt.core.QObject)} * with parent = null.

*/ public QTimer() { this((io.qt.core.QObject)null); } /** *

See QTimer::QTimer(QObject*)

*/ public QTimer(io.qt.core.QObject parent){ super((QPrivateConstructor)null); initialize_native(this, parent); } private native static void initialize_native(QTimer instance, io.qt.core.QObject parent); /** *

See QTimer::bindableActive()

*/ @io.qt.QtPropertyBindable(name="active") @io.qt.QtUninvokable public final io.qt.core.QBooleanBindable bindableActive(){ return bindableActive_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QBooleanBindable bindableActive_native(long __this__nativeId); /** *

The timeout interval in milliseconds

*

See QTimer::bindableInterval()

*/ @io.qt.QtPropertyBindable(name="interval") @io.qt.QtUninvokable public final io.qt.core.QIntBindable bindableInterval(){ return bindableInterval_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QIntBindable bindableInterval_native(long __this__nativeId); /** *

Whether the timer is a single-shot timer

*

See QTimer::bindableSingleShot()

*/ @io.qt.QtPropertyBindable(name="singleShot") @io.qt.QtUninvokable public final io.qt.core.QBooleanBindable bindableSingleShot(){ return bindableSingleShot_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QBooleanBindable bindableSingleShot_native(long __this__nativeId); /** *

Controls the accuracy of the timer

*

See QTimer::bindableTimerType()

*/ @io.qt.QtPropertyBindable(name="timerType") @io.qt.QtUninvokable public final io.qt.core.QBindable bindableTimerType(){ return bindableTimerType_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native io.qt.core.QBindable bindableTimerType_native(long __this__nativeId); /** *

See QTimer::interval()const

*/ @io.qt.QtPropertyReader(name="interval") @io.qt.QtUninvokable public final int interval(){ return interval_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int interval_native_constfct(long __this__nativeId); /** *

See QTimer::isActive()const

*/ @io.qt.QtPropertyReader(name="active") @io.qt.QtPropertyStored("false") @io.qt.QtUninvokable public final boolean isActive(){ return isActive_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native boolean isActive_native_constfct(long __this__nativeId); /** *

See QTimer::isSingleShot()const

*/ @io.qt.QtPropertyReader(name="singleShot") @io.qt.QtUninvokable public final boolean isSingleShot(){ return isSingleShot_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native boolean isSingleShot_native_constfct(long __this__nativeId); /** *

See QTimer::remainingTime()const

*/ @io.qt.QtPropertyReader(name="remainingTime") @io.qt.QtUninvokable public final int remainingTime(){ return remainingTime_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int remainingTime_native_constfct(long __this__nativeId); /** *

See QTimer::setInterval(int)

*/ @io.qt.QtPropertyWriter(name="interval") @io.qt.QtUninvokable public final void setInterval(int msec){ setInterval_native_int(QtJambi_LibraryUtilities.internal.nativeId(this), msec); } @io.qt.QtUninvokable private native void setInterval_native_int(long __this__nativeId, int msec); /** *

See QTimer::setSingleShot(bool)

*/ @io.qt.QtPropertyWriter(name="singleShot") @io.qt.QtUninvokable public final void setSingleShot(boolean singleShot){ setSingleShot_native_bool(QtJambi_LibraryUtilities.internal.nativeId(this), singleShot); } @io.qt.QtUninvokable private native void setSingleShot_native_bool(long __this__nativeId, boolean singleShot); /** *

See QTimer::setTimerType(Qt::TimerType)

*/ @io.qt.QtPropertyWriter(name="timerType") @io.qt.QtUninvokable public final void setTimerType(io.qt.core.Qt.TimerType atype){ setTimerType_native_Qt_TimerType(QtJambi_LibraryUtilities.internal.nativeId(this), atype.value()); } @io.qt.QtUninvokable private native void setTimerType_native_Qt_TimerType(long __this__nativeId, int atype); /** *

See QTimer::start()

*/ public final void start(){ start_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } private native void start_native(long __this__nativeId); /** *

See QTimer::start(int)

*/ public final void start(int msec){ start_native_int(QtJambi_LibraryUtilities.internal.nativeId(this), msec); } private native void start_native_int(long __this__nativeId, int msec); /** *

See QTimer::stop()

*/ public final void stop(){ stop_native(QtJambi_LibraryUtilities.internal.nativeId(this)); } private native void stop_native(long __this__nativeId); /** *

See QTimer::timerId()const

*/ @io.qt.QtUninvokable public final int timerId(){ return timerId_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native int timerId_native_constfct(long __this__nativeId); /** *

See QTimer::timerType()const

*/ @io.qt.QtPropertyReader(name="timerType") @io.qt.QtUninvokable public final io.qt.core.Qt.TimerType timerType(){ return io.qt.core.Qt.TimerType.resolve(timerType_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this))); } @io.qt.QtUninvokable private native int timerType_native_constfct(long __this__nativeId); /** *

See QObject::timerEvent(QTimerEvent*)

*/ @io.qt.QtUninvokable protected void timerEvent(io.qt.core.QTimerEvent arg__1){ timerEvent_native_QTimerEvent_ptr(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.checkedNativeId(arg__1)); } @io.qt.QtUninvokable private native void timerEvent_native_QTimerEvent_ptr(long __this__nativeId, long arg__1); /** * Constructor for internal use only. * @param p expected to be null. */ @io.qt.NativeAccess protected QTimer(QPrivateConstructor p) { super(p); } /** * Constructor for internal use only. * It is not allowed to call the declarative constructor from inside Java. */ @io.qt.NativeAccess protected QTimer(QDeclarativeConstructor constructor) { super((QPrivateConstructor)null); initialize_native(this, constructor); } @io.qt.QtUninvokable private static native void initialize_native(QTimer instance, QDeclarativeConstructor constructor); private static class QSingleShotTimer extends QObject { private int timerId; public final Signal0 timeout = new Signal0(); private final QObject receiver; private final QMetaObject.Slot0 slot; private QSingleShotTimer(int msec, Qt.TimerType timeType, QObject obj, String method) { super(QAbstractEventDispatcher.instance()); this.slot = null; this.receiver = null; if(QAbstractEventDispatcher.instance()==null){ dispose(); return; } QtJambi_LibraryUtilities.internal.setCppOwnership(this); timeout.connect(obj, method); timerId = startTimer(msec, timeType); } private QSingleShotTimer(int msec, Qt.TimerType timeType, QObject obj, QMetaObject.Slot0 slot) { super(QAbstractEventDispatcher.instance()); QMetaObject.Connection connection = timeout.connect(slot); if(connection==null || (obj!=null && connection.receiver()!=obj)) { this.slot = slot; this.receiver = obj; }else { this.slot = null; this.receiver = null; } if(obj!=null && thread()!=obj.thread()) { QCoreApplication.instance().aboutToQuit.connect(this::disposeLater); setParent(null); this.moveToThread(obj.thread()); }else if(QAbstractEventDispatcher.instance()==null){ dispose(); return; } QtJambi_LibraryUtilities.internal.setCppOwnership(this); timerId = startTimer(msec, timeType); } protected void timerEvent(QTimerEvent e) { if (timerId > 0) killTimer(timerId); timerId = -1; if(slot!=null) { if(receiver==null || !receiver.isDisposed()) { try { slot.invoke(); } catch (Throwable e1) { } } }else { timeout.emit(); } disposeLater(); } } /** * This static function calls a slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or create a local QTimer object. * * The receiver is the receiving object and the member is the slot. The * time interval is msec milliseconds. * * @see #start() */ public static void singleShot(int msec, QObject obj, String method) { singleShot(msec, defaultTypeFor(msec), obj, method); } /** * This static function calls slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or create a local QTimer object. * * The time interval is msec milliseconds. * * If context is destroyed before the interval occurs, the method will not be called. * The function will be run in the thread of context. The context's thread must have * a running Qt event loop. * * @see #start() * @since 5.4 */ public static void singleShot(int msec, QObject context, QMetaObject.Slot0 slot) { singleShot(msec, defaultTypeFor(msec), context, slot); } /** * This static function calls a slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or create a local QTimer object. * * The receiver is the receiving object and the member is the slot. The * time interval is msec milliseconds. The timerType affects the * accuracy of the timer. * * @see #start() */ public static void singleShot(int msec, Qt.TimerType timeType, QObject obj, String method) { new QSingleShotTimer(msec, timeType, obj, method); } /** * This static function calls slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or * create a local QTimer object. * * The time interval is msec milliseconds. * * @see #start() * @since 5.4 */ public static void singleShot(int msec, QMetaObject.Slot0 slot) { singleShot(msec, defaultTypeFor(msec), null, slot); } /** * This static function calls slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or * create a local QTimer object. * * The time interval is msec milliseconds. The timerType affects the * accuracy of the timer. * * @see #start() * @since 5.4 */ public static void singleShot(int msec, Qt.TimerType timeType, QMetaObject.Slot0 slot) { singleShot(msec, timeType, null, slot); } /** * This static function calls slot after a given time interval. * * It is very convenient to use this function because you do not need * to bother with a timerEvent or * create a local QTimer object. * * The time interval is msec milliseconds. The timerType affects the * accuracy of the timer. * * If context is destroyed before the interval occurs, the method will not be called. * The function will be run in the thread of context. The context's thread must have * a running Qt event loop. * * @see #start() * @since 5.4 */ public static void singleShot(int msec, Qt.TimerType timeType, QObject context, QMetaObject.Slot0 slot) { new QSingleShotTimer(msec, timeType, context, slot); } private static Qt.TimerType defaultTypeFor(int msecs){ return msecs >= 2000 ? Qt.TimerType.CoarseTimer : Qt.TimerType.PreciseTimer; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy