CDPBasePicture Class
The Picture widget can show raster images/pixmaps and scalable vector graphics (.svg). More...
Header: | #include <CDPBaseWidgets/CDPBasePicture.h> |
Inherits: | CDPBaseWidget, RoutingContainerBase, and |
Inherited By: |
Properties
|
|
- 6 properties inherited from CDPBaseWidget
Public Functions
CDPBasePicture(QWidget *parent = 0) | |
void | addWidget(QWidget *widget, const QString &title = "") override |
virtual Qt::Alignment | alignment() |
virtual bool | cdpPosCenter() |
virtual bool | cdpPosRelative() |
QString | cdpPosXRouting() |
QString | cdpPosYRouting() |
QString | cdpRotationRouting() |
QString | cdpStyle() |
virtual bool | lockAspectRatio() |
virtual bool | minSizeHintEnabled() const |
virtual const QPixmap & | pixmap() |
void | removeWidgets() override |
virtual int | rotation() |
virtual bool | rotationVertical() |
virtual bool | scaledContents() const |
virtual void | setAlignment(Qt::Alignment alignment) |
virtual void | setCdpPosCenter(bool enable) |
virtual void | setCdpPosRelative(bool enable) |
void | setCdpPosXRouting(QString routing) |
void | setCdpPosYRouting(QString routing) |
void | setCdpRotationRouting(QString routing) |
void | setCdpStyle(QString routing) |
virtual void | setMinSizeHint(bool enable) |
virtual void | setPixmap(const QPixmap &pixmap) |
virtual void | setRotationVertical(bool enable) |
virtual void | setSvgFile(const QString &svg) |
QSize | sizeHint() const override |
virtual QString | svgFile() |
Reimplemented Public Functions
virtual void | setIQtCDPPointer(IQtCDP *pIQtCDP) override |
- 8 public functions inherited from CDPBaseWidget
- 3 public functions inherited from RoutingContainerBase
- 4 public functions inherited from CDPBaseControlVisible
Public Slots
virtual void | forceWidgetStyle(int style) |
virtual void | forceWidgetStyle(double style) |
virtual void | setLockAspectRatio(bool enable) |
virtual void | setPosX(double posX) |
virtual void | setPosX(int posX) |
virtual void | setPosY(double posY) |
virtual void | setPosY(int posY) |
virtual void | setRelativePosX(double posX) |
virtual void | setRelativePosY(double posY) |
virtual void | setRotation(int rotation) |
virtual void | setRotation(double rotation) |
virtual void | setScaledContents(bool enable) |
virtual void | setWidgetStyle(int style) |
virtual void | setWidgetTheme(const QString &theme) |
- 10 public slots inherited from CDPBaseWidget
Signals
- 1 signal inherited from CDPBaseWidget
Protected Functions
QWidget * | canvasWidget() const |
QWidget * | convertToLoaderWidget(QWidget *widget) const |
bool | eventFilter(QObject *watched, QEvent *event) override |
void | initPixmap(QSize pixSize) |
virtual void | loadSvg() |
virtual QSize | minimumSizeHint() const |
void | mousePressEvent(QMouseEvent *ev) override |
void | mouseReleaseEvent(QMouseEvent *ev) override |
void | paintEvent(QPaintEvent *ev) override |
QSize | pixmapTargetSize(const QSize &pixSize) |
virtual void | processSvgFile(QString svg) |
QPoint | rectPos(const QRect &rect) |
void | resizeEvent(QResizeEvent *ev) override |
- 1 protected function inherited from CDPBaseControlVisible
Protected Slots
void | initDeprecated() |
Detailed Description
The Picture widget can show raster images/pixmaps and scalable vector graphics (.svg).
There are several properties that can be used to display the picture depending on picture type and usage. Aspect ratio can be toggled on/off and there are properties for scaling and aligning the picture inside the widget when picture has a fixed size. The picture can also be rotated and have a minimum size hint (when used in layouts) as described in the following table.
Name | Description |
---|---|
alignment | Align the picture within the widget (will have no effect when scaledContents is true and lockAspectRatio is false). |
scaledContents | Enable this property to make the picture scalable. |
lockAspectRatio | Enable this property to lock the original aspect ratio (will only have effect when scaledContents is enabled). |
minimumSizeHint | Enable minimum size hint (will adjust size when used in layouts). |
rotation | Set to rotate the image ( angle in degrees ). |
The Picture widgets have several properties to enable animations and control from CDP objects/properties. Adding routing to one or more of the following properties will allow switching style, position and rotation.
Name | Description |
---|---|
cdpPosRelative | This property holds whether to set routed positions in pixels or as factors relative to parent size. |
cdpPosXRouting | This property holds the routing to the CDP object/property that is to control picture x position. |
cdpPosYRouting | This property holds the routing to the CDP object/property that is to control picture y position. |
cdpRotationRouting | This property holds the routing to the CDP object/property that is to control the rotation of the picture. |
cdpStyleRouting | This property holds the routing to the CDP object/property that is to control which style element in the SVG file to show. |
The above properties provide a straightforward way to, for instance, place images on a map, making it easy to show things like ship locations. When you're not sure how many objects/nodes you need to display, you can employ the Node Container to enable real-time picture updating.
Note: Using the property named pixmap instead of the svgFile might result in a pixelated end result, and will ignore properties related to styling.
Styling by SVG
Use the svgFile property to style the widget using a svg file. Styling by svg enables switching between different themes in runtime (as long as the files are placed at identical locations within theme directories).
Main element structure
The structure of the svg is currently very simple and not really necessary. Users should consider using an ordinary svg without thinking about the structure. Note however, that the widget support styles and can thus be used as a picture sequence.
svg └─── Layer1 └─── cdpPicture (element group) ├─── < Path > (transparent rect/path) └─── < Group > (graphics)
The following table explains the named elements in more detail.
Property | Type | Description |
---|---|---|
cdpPicture | rect or an element group containing a rect | The cdpPicture should contain the actual background graphics. To ensure that the svg parser gets the correct size (and aspect ratio), we have to place a transparent rect along with the graphics within a group element. |
Style element structure
The picture also supports styles that can be changed by the widgetStyle property or by cdp signal/object. Styles makes it possible to use the widget as a picture sequence.
svg ├─── Layer1 │ └─── ... (see previous section) └─── Styles └─── cdpPictureStyleX (element group) ├─── < Path > (transparent rect/path) └─── < Group > (graphics)
Property Documentation
alignment : Qt::Alignment
Align the picture within the widget (will have no effect when scaledContents is true and lockAspectRatio is false).
Access functions:
virtual Qt::Alignment | alignment() |
virtual void | setAlignment(Qt::Alignment alignment) |
cdpFullTargetRouting : const QString
cdpPosCenter : bool
This property holds whether to position the widget relative to its center or top left corner.
Enabling this feature and setting position (0,0) will show the picture in the top left corner of its parent, but as it is positioned on center, only the bottom right corner of the picture will be visible. Further, having the center option disabled will ensure that the entire picture always shows as long as position is set between (0,0) and the (height, width) of the parent.
Access functions:
virtual bool | cdpPosCenter() |
virtual void | setCdpPosCenter(bool enable) |
cdpPosRelative : bool
This property holds whether to set routed positions in pixels or as factors relative to parent size.
Access functions:
virtual bool | cdpPosRelative() |
virtual void | setCdpPosRelative(bool enable) |
cdpPosXRouting : QString
This property holds the routing to the object that is to control x position.
Access functions:
QString | cdpPosXRouting() |
void | setCdpPosXRouting(QString routing) |
cdpPosYRouting : QString
This property holds the routing to the object that is to control y position.
Access functions:
QString | cdpPosYRouting() |
void | setCdpPosYRouting(QString routing) |
cdpRotationRouting : QString
This property holds the routing to the CDP object/property that is to control the rotation of the picture.
Access functions:
QString | cdpRotationRouting() |
void | setCdpRotationRouting(QString routing) |
cdpStyleRouting : QString
Set the routing of the CDP object that is to change the widget svg style.
Access functions:
QString | cdpStyle() |
void | setCdpStyle(QString routing) |
cdpTargetRouting : const QString
lockAspectRatio : bool
Enable this property to lock the original aspect ratio (will only have effect when scaledContents is enabled).
Access functions:
virtual bool | lockAspectRatio() |
virtual void | setLockAspectRatio(bool enable) |
minimumSizeHint : bool
Enable minimum size hint (will adjust size when used in layouts).
Access functions:
virtual bool | minSizeHintEnabled() const |
virtual void | setMinSizeHint(bool enable) |
pixmap : QPixmap
Use this property to add a image to the widget. Note that though ordinary svg files can be added, they should rather be added in the svgFile property as this makes them scalable without loosing quality.
Supports the following formats: .jpg , .pgn , .bmp , .gif , .tif , and more
Access functions:
virtual const QPixmap & | pixmap() |
virtual void | setPixmap(const QPixmap &pixmap) |
rotation : int
This property holds the number of degrees to rotate the picture.
The picture is rotated clockwise. Negative numbers are not supported.
Access functions:
virtual int | rotation() |
virtual void | setRotation(int rotation) |
virtual void | setRotation(double rotation) |
rotationVertical : bool
Access functions:
virtual bool | rotationVertical() |
virtual void | setRotationVertical(bool enable) |
scaledContents : bool
Enable this property to make the picture scalable.
Access functions:
virtual bool | scaledContents() const |
virtual void | setScaledContents(bool enable) |
svgFile : QString
This property specifies the path to the SVG file to show in the widget. The SVG does not have to be in the CDP format. Ordinary SVG files will load nicely and be scalable similar to the ones with CDP elements.
The property will also accept raster formats like .png. This property is often preferred over pixmap, as it supports themeRootDir, theme switching and shows full path in designer tools.
Access functions:
virtual QString | svgFile() |
virtual void | setSvgFile(const QString &svg) |
See also pixmap.
Member Function Documentation
CDPBasePicture::CDPBasePicture(QWidget *parent = 0)
Default constructs an instance of CDPBasePicture.
void CDPBasePicture::addWidget(QWidget *widget, const QString &title = "")
[protected]
QWidget *CDPBasePicture::canvasWidget() const
[signal]
void CDPBasePicture::clicked()
[protected]
QWidget *CDPBasePicture::convertToLoaderWidget(QWidget *widget) const
[protected]
bool CDPBasePicture::eventFilter(QObject *watched, QEvent *event)
Implemented to update relative position when parent size is changed.
Returns base implementation with watched and event as arguments.
[virtual slot]
void CDPBasePicture::forceWidgetStyle(int style)
[virtual slot]
void CDPBasePicture::forceWidgetStyle(double style)
[protected slot]
void CDPBasePicture::initDeprecated()
[protected]
void CDPBasePicture::initPixmap(QSize pixSize)
[virtual protected]
void CDPBasePicture::loadSvg()
[virtual protected]
QSize CDPBasePicture::minimumSizeHint() const
[protected]
void CDPBasePicture::mousePressEvent(QMouseEvent *ev)
[protected]
void CDPBasePicture::mouseReleaseEvent(QMouseEvent *ev)
[protected]
void CDPBasePicture::paintEvent(QPaintEvent *ev)
[protected]
QSize CDPBasePicture::pixmapTargetSize(const QSize &pixSize)
[signal]
void CDPBasePicture::pressed()
[virtual protected]
void CDPBasePicture::processSvgFile(QString svg)
[protected]
QPoint CDPBasePicture::rectPos(const QRect &rect)
void CDPBasePicture::removeWidgets()
[protected]
void CDPBasePicture::resizeEvent(QResizeEvent *ev)
[override virtual]
void CDPBasePicture::setIQtCDPPointer(IQtCDP *pIQtCDP)
[virtual slot]
void CDPBasePicture::setPosX(double posX)
[virtual slot]
void CDPBasePicture::setPosX(int posX)
[virtual slot]
void CDPBasePicture::setPosY(double posY)
[virtual slot]
void CDPBasePicture::setPosY(int posY)
[virtual slot]
void CDPBasePicture::setRelativePosX(double posX)
[virtual slot]
void CDPBasePicture::setRelativePosY(double posY)
[virtual slot]
void CDPBasePicture::setWidgetStyle(int style)
[virtual slot]
void CDPBasePicture::setWidgetTheme(const QString &theme)
QSize CDPBasePicture::sizeHint() const
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.