NDEVR
API Documentation

A widget that shows a raster image or icon. More...

Public Types

enum  ViewMode { e_keep , e_zoom_in , e_zoom_out , e_stretch }
 Enumerates how the image is scaled to fit the widget frame. More...

Public Member Functions

 ImageView (const StringView &image, QWidget *parent=nullptr)
 Constructs an ImageView with an initial image.
 ImageView (QWidget *parent=nullptr)
 Constructs an empty ImageView.
void clearImage ()
 Clears the currently displayed image.
QIcon icon ()
 Returns the currently displayed QIcon.
QSize minimumSizeHint () const override
 Returns the minimum size hint, which is zero to allow full shrinking.
void paintEvent (QPaintEvent *event) override
 Paints the image within the widget bounds using the current view mode.
void resizeEvent (QResizeEvent *resize_event) override
 Handles resize events, updating the cached scaled image.
void setAlignment (Qt::Alignment alignment)
 Sets the alignment of the image within the widget.
void setAllowImageContextMenu (bool allow_context_menu)
 Sets whether a context menu is shown when right-clicking the image.
void setAutoResize (bool auto_resize)
 Sets whether the widget automatically resizes to fit its content.
void setBlendFactor (fltp04 blend_factor)
 Sets the blend factor between the primary and blend images.
void setBlendImage (const QPixmap &blend_image)
 Sets a secondary image to blend with the primary image.
void setForceAspectRatioH (bool force)
 Sets whether to force the image height to maintain the aspect ratio.
void setForceAspectRatioW (bool force)
 Sets whether to force the image width to maintain the aspect ratio.
void setIcon (const QIcon &image, QIcon::Mode mode=QIcon::Mode::Normal)
 Sets the displayed icon from a QIcon.
void setIconID (const StringView &image, bool force_refresh=false)
 Sets the displayed icon by its resource ID.
void setIconMode (QIcon::Mode mode)
 Sets the icon rendering mode.
void setIgnoreDPR (bool ignore)
 Sets whether to ignore the device pixel ratio when rendering.
void setImage (const QImage &image)
 Sets the displayed image from a QImage.
void setImage (const QPixmap &pixmap)
 Sets the displayed image from a QPixmap.
void setImageID (const StringView &image, bool force_refresh=false)
 Sets the displayed image by its resource ID.
void setImageScale (fltp08 scale)
 Sets a custom scale factor for the displayed icon.
void setSizeHintPixelMetric (QStyle::PixelMetric metric)
 Sets the size hint based on a QStyle pixel metric.
void setSmoothResize (bool smooth_resize)
 Sets whether smooth (bilinear) scaling is used when resizing.
void setViewMode (ViewMode mode)
 Sets the view mode controlling how the image fits the widget.
QSize sizeHint () const override
 Returns the recommended size for this widget.

Protected Member Functions

void showContextMenuSlot (const QPoint &pos)
 Shows a context menu at the given position for image operations.

Detailed Description

A widget that shows a raster image or icon.


Definition at line 43 of file ImageView.h.

Member Enumeration Documentation

◆ ViewMode

Enumerates how the image is scaled to fit the widget frame.

Enumerator
e_keep 

No size adjustment; display at native resolution.

e_zoom_in 

Crop the image to fill the frame.

e_zoom_out 

Scale the entire image to fit within the frame.

e_stretch 

Stretch the image to exactly match the frame dimensions.

Definition at line 50 of file ImageView.h.

Constructor & Destructor Documentation

◆ ImageView() [1/2]

ImageView::ImageView ( const StringView & image,
QWidget * parent = nullptr )

Constructs an ImageView with an initial image.

Parameters
[in]imageThe image ID or path to display.
[in]parentThe parent widget.

Referenced by ImageView().

◆ ImageView() [2/2]

ImageView::ImageView ( QWidget * parent = nullptr)

Constructs an empty ImageView.

Parameters
[in]parentThe parent widget.

References ImageView().

Member Function Documentation

◆ icon()

QIcon ImageView::icon ( )
inline

Returns the currently displayed QIcon.

Returns
The QIcon.

Definition at line 203 of file ImageView.h.

◆ minimumSizeHint()

QSize ImageView::minimumSizeHint ( ) const
inlineoverride

Returns the minimum size hint, which is zero to allow full shrinking.

Returns
A zero-size QSize.

Definition at line 141 of file ImageView.h.

◆ paintEvent()

void ImageView::paintEvent ( QPaintEvent * event)
override

Paints the image within the widget bounds using the current view mode.

Parameters
[in]eventThe paint event.

◆ resizeEvent()

void ImageView::resizeEvent ( QResizeEvent * resize_event)
override

Handles resize events, updating the cached scaled image.

Parameters
[in]resize_eventThe resize event.

◆ setAlignment()

void ImageView::setAlignment ( Qt::Alignment alignment)

Sets the alignment of the image within the widget.

Parameters
[in]alignmentThe Qt alignment flags.

◆ setAllowImageContextMenu()

void ImageView::setAllowImageContextMenu ( bool allow_context_menu)

Sets whether a context menu is shown when right-clicking the image.

Parameters
[in]allow_context_menuWhether to enable the context menu.

◆ setAutoResize()

void ImageView::setAutoResize ( bool auto_resize)
inline

Sets whether the widget automatically resizes to fit its content.

Parameters
[in]auto_resizeWhether to enable auto-resize.

Definition at line 149 of file ImageView.h.

◆ setBlendFactor()

void ImageView::setBlendFactor ( fltp04 blend_factor)

Sets the blend factor between the primary and blend images.

Parameters
[in]blend_factor0.0 = no blend, 1.0 = only blend image.

◆ setBlendImage()

void ImageView::setBlendImage ( const QPixmap & blend_image)

Sets a secondary image to blend with the primary image.

Parameters
[in]blend_imageThe pixmap to blend.

◆ setForceAspectRatioH()

void ImageView::setForceAspectRatioH ( bool force)

Sets whether to force the image height to maintain the aspect ratio.

Parameters
[in]forceWhether to force height aspect ratio.

◆ setForceAspectRatioW()

void ImageView::setForceAspectRatioW ( bool force)

Sets whether to force the image width to maintain the aspect ratio.

Parameters
[in]forceWhether to force width aspect ratio.

◆ setIcon()

void ImageView::setIcon ( const QIcon & image,
QIcon::Mode mode = QIcon::Mode::Normal )

Sets the displayed icon from a QIcon.

Parameters
[in]imageThe QIcon to display.
[in]modeThe icon mode (Normal, Disabled, Active, Selected).

◆ setIconID()

void ImageView::setIconID ( const StringView & image,
bool force_refresh = false )

Sets the displayed icon by its resource ID.

Parameters
[in]imageThe icon resource identifier.
[in]force_refreshWhether to force reloading even if already set.

◆ setIconMode()

void ImageView::setIconMode ( QIcon::Mode mode)

Sets the icon rendering mode.

Parameters
[in]modeThe icon mode to use.

◆ setIgnoreDPR()

void ImageView::setIgnoreDPR ( bool ignore)

Sets whether to ignore the device pixel ratio when rendering.

Parameters
[in]ignoreWhether to ignore DPR.

◆ setImage() [1/2]

void ImageView::setImage ( const QImage & image)

Sets the displayed image from a QImage.

Parameters
[in]imageThe QImage to display.

◆ setImage() [2/2]

void ImageView::setImage ( const QPixmap & pixmap)

Sets the displayed image from a QPixmap.

Parameters
[in]pixmapThe pixmap to display.

◆ setImageID()

void ImageView::setImageID ( const StringView & image,
bool force_refresh = false )

Sets the displayed image by its resource ID.

Parameters
[in]imageThe image resource identifier.
[in]force_refreshWhether to force reloading even if already set.

◆ setImageScale()

void ImageView::setImageScale ( fltp08 scale)
inline

Sets a custom scale factor for the displayed icon.

Parameters
[in]scaleThe scale multiplier.

Definition at line 180 of file ImageView.h.

◆ setSizeHintPixelMetric()

void ImageView::setSizeHintPixelMetric ( QStyle::PixelMetric metric)

Sets the size hint based on a QStyle pixel metric.

Parameters
[in]metricThe pixel metric to use for the size hint.

◆ setSmoothResize()

void ImageView::setSmoothResize ( bool smooth_resize)
inline

Sets whether smooth (bilinear) scaling is used when resizing.

Parameters
[in]smooth_resizeWhether to use smooth transformation.

Definition at line 107 of file ImageView.h.

◆ setViewMode()

void ImageView::setViewMode ( ViewMode mode)
inline

Sets the view mode controlling how the image fits the widget.

Parameters
[in]modeThe ViewMode to use.

Definition at line 157 of file ImageView.h.

◆ sizeHint()

QSize ImageView::sizeHint ( ) const
override

Returns the recommended size for this widget.

Returns
The preferred size hint.

The documentation for this class was generated from the following file: