Module qtjambi
Package io.qt.core

Class QScopedPointer<O>

java.lang.Object
io.qt.core.QScopedPointer<O>
All Implemented Interfaces:
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()
    • get

      @QtUninvokable public O get()
    • take

      @QtUninvokable public O take()
    • reset

      @QtUninvokable public void reset(O other)
    • isNull

      @QtUninvokable public boolean isNull()
    • swap

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

      @QtUninvokable public void close()
      Specified by:
      close in interface AutoCloseable
    • disposing

      @QtUninvokable public static <O extends QtObjectInterface> QScopedPointer<O> disposing(O data)
    • disposingLater

      @QtUninvokable public static <O extends QObject> QScopedPointer<O> disposingLater(O data)
    • cleanup

      @QtUninvokable @Deprecated public static <O> QScopedPointer<O> cleanup(O data, Consumer<O> cleanup)
      Deprecated.
    • cleanup

      @QtUninvokable public static <O> QScopedPointer<O> cleanup(Consumer<O> cleanup, O data)
    • 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