Module qtjambi
Package io.qt.core

Class QScopedPointer<O>

java.lang.Object
io.qt.core.QScopedPointer<O>
All Implemented Interfaces:
MetaTypeUtility.SmartPointer, AutoCloseable

public final class QScopedPointer<O> extends Object implements AutoCloseable

Java wrapper for Qt class QScopedPointer to be used inside a try-with-resource block.

Example:

try(var pointer = QScopedPointer.disposing(new QDialog())){
    QDialog dialog = pointer.get();
    dialog.exec();
}
// dialog is disposed

Alternatively, performAndDispose disposes a recource after calling a lambda expression:

QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
  • Method Details

    • data

      @QtUninvokable public O data()

      Returns the object stored by this scoped pointer

      See QScopedPointer::data()const.

      Returns:
      data
    • get

      @QtUninvokable public O get()
      See Also:
    • take

      @QtUninvokable public O take()

      Removes and returns the object stored by this scoped pointer without cleanup

      Returns:
      data
    • reset

      @QtUninvokable public void reset(O other)

      performs cleanup operation on the contained object and sets new reference.

      See QScopedPointer::reset(T*).

    • reset

      @QtUninvokable public void reset()
      Overloaded function for reset(Object) with other=null.
    • isNull

      @QtUninvokable public boolean isNull()
    • swap

      @QtUninvokable public void swap(QScopedPointer<O> other)
    • close

      @QtUninvokable public void close()
      performs the cleanup operation
      Specified by:
      close in interface AutoCloseable
    • disposing

      @QtUninvokable public static <O extends QtObjectInterface> QScopedPointer<O> disposing(O data)
      Creates a scoped pointer for the given object performing QtObjectInterface.dispose() at cleanup.
      Parameters:
      data - the contained object
      Returns:
      scoped pointer
    • disposingLater

      @QtUninvokable public static <O extends QObject> QScopedPointer<O> disposingLater(O data)
      Creates a scoped pointer for the given object performing QObject.disposeLater() at cleanup.
      Parameters:
      data - the contained object
      Returns:
      scoped pointer
    • cleanup

      @QtUninvokable @Deprecated(forRemoval=true) public static <O> QScopedPointer<O> cleanup(O data, Consumer<O> cleanup)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • cleanup

      @QtUninvokable public static <O> QScopedPointer<O> cleanup(Consumer<O> cleanup, O data)
      Creates a scoped pointer for the given object performing the given operation at cleanup.
      Parameters:
      cleanup - operation performed at cleanup
      data - the contained object
      Returns:
      scoped pointer
    • performAndDispose

      @QtUninvokable public static <O extends QtObjectInterface> void performAndDispose(Consumer<O> action, O data)
      Performs an action on a resource which will be disposes subsequently. QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
      Parameters:
      action - the action
      data - the resource
    • performAndDisposeLater

      @QtUninvokable public static <O extends QObject> void performAndDisposeLater(Consumer<O> action, O data)
      Performs an action on a QObject resource which will be called QObject.disposeLater() subsequently. QScopedPointer.performAndDispose(QDialog::exec, new QDialog());
      Parameters:
      action - the action
      data - the resource
    • performAndCleanup

      @QtUninvokable public static <O> void performAndCleanup(Consumer<O> action, Consumer<O> cleanup, O data)
      Performs an action on a resource which will be cleaned up subsequently. QScopedPointer.performAndCleanup(object-> {               ...//action           },           object -> { object.cleanup(); }, new CustomObject() );
      Parameters:
      action - the action
      data - the resource
    • performAndDispose

      @QtUninvokable public static <O extends QtObjectInterface, R> R performAndDispose(Function<O,R> action, O data)
      Performs an action on a resource which will be disposes subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDisposeLater

      @QtUninvokable public static <O extends QObject, R> R performAndDisposeLater(Function<O,R> action, O data)
      Performs an action on a QObject resource which will be called QObject.disposeLater() subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndCleanup

      @QtUninvokable public static <O, R> R performAndCleanup(Function<O,R> action, Consumer<O> cleanup, O data)
      Performs an action on a resource which will be cleaned up subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDispose

      @QtUninvokable public static <O extends QtObjectInterface> int performAndDispose(ToIntFunction<O> action, O data)
      Performs an action on a resource which will be disposes subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDisposeLater

      @QtUninvokable public static <O extends QObject> int performAndDisposeLater(ToIntFunction<O> action, O data)
      Performs an action on a QObject resource which will be called QObject.disposeLater() subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndCleanup

      @QtUninvokable public static <O> int performAndCleanup(ToIntFunction<O> action, Consumer<O> cleanup, O data)
      Performs an action on a resource which will be cleaned up subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDispose

      @QtUninvokable public static <O extends QtObjectInterface> double performAndDispose(ToDoubleFunction<O> action, O data)
      Performs an action on a resource which will be disposes subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDisposeLater

      @QtUninvokable public static <O extends QObject> double performAndDisposeLater(ToDoubleFunction<O> action, O data)
      Performs an action on a QObject resource which will be called QObject.disposeLater() subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndCleanup

      @QtUninvokable public static <O> double performAndCleanup(ToDoubleFunction<O> action, Consumer<O> cleanup, O data)
      Performs an action on a resource which will be cleaned up subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDispose

      @QtUninvokable public static <O extends QtObjectInterface> long performAndDispose(ToLongFunction<O> action, O data)
      Performs an action on a resource which will be disposes subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndDisposeLater

      @QtUninvokable public static <O extends QObject> long performAndDisposeLater(ToLongFunction<O> action, O data)
      Performs an action on a QObject resource which will be called QObject.disposeLater() subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result
    • performAndCleanup

      @QtUninvokable public static <O> long performAndCleanup(ToLongFunction<O> action, Consumer<O> cleanup, O data)
      Performs an action on a resource which will be cleaned up subsequently.
      Parameters:
      action - the action
      data - the resource
      Returns:
      result