ADTF Qt5
Loading...
Searching...
No Matches
Example Demo Qt5 UI

Description

Shows how to customize UI with Qt in Qt5 ADTF XSystem UI Service.

Prebuilt Binaries

Source Code

./examples/demo_adtfplugins/demo_qt5_ui/

Progress Bar

test_dialog.h

/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#pragma once
#include <QDialog>
#include <ui_demo_filter.h>
class cTestDialog : public QDialog
{
Q_OBJECT
public:
cTestDialog(QWidget* pParent);
Ui_TestUI ui;
};

Color Table Model

progress_bar_delegate.h

#include <QApplication>
#include <QStyledItemDelegate>
#include <QPainter>
using namespace adtf::ui;
class ProgressBarDelegate : public QStyledItemDelegate
{
public:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
// Important: First call drawControl for the base item view
// cares about default hovering / selection / and column grid at the end of the cell
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &option, painter, option.widget);
// Assume progress value comes as int from UserRole + 1 (could be any role you choose)
bool ok;
int progress = index.data(Qt::UserRole + 1).toInt(&ok);
if (ok)
{
//
// For painting a progress bar there is already built in functionaliy ...
//
// QStyleOptionProgressBar progressBarOption;
//
// progressBarOption.rect = option.rect;
// progressBarOption.minimum = 0;
// progressBarOption.maximum = 100;
// progressBarOption.progress = progress;
// progressBarOption.text = QString::number(progress) + '%';
// progressBarOption.textAlignment = Qt::AlignCenter | Qt::AlignVCenter;
// progressBarOption.textVisible = true;
// progressBarOption.state = option.state;
// progressBarOption.palette = option.palette;
//
// QApplication::style()->drawControl(QStyle::CE_ProgressBarContents, &progressBarOption, painter,
// option.widget);
//
// ...but the intention of this demo is how to do that from scratch...
//
// and here we go...
//
//
// First reduce cell width by 1 to not overdraw the grid line between columns
QRect rect = option.rect.adjusted(0, 0, -1, 0);
// Get information about dark mode and scaling
bool isDarkMode = QApplication::palette().color(QPalette::Window).lightness() < 127;
double scaling = option.font.pointSizeF() / 10.0;
painter->save();
// The exising hover & background selection color does not fit to our needs as it
// would interfere with the progress bar color. Therefore we do our special drawing here
QColor backGround = isDarkMode ? QColor("#343434") : QColor("#f4f4f4");
if (option.state & QStyle::State_MouseOver) // hover effect for background
{
painter->fillRect(rect, isDarkMode ? backGround.lighter(120) : backGround.darker(110));
}
else // normal background painting depending on dark mode
{
painter->fillRect(rect, backGround);
}
double percentage = progress / 100.0;
int progressWidth = static_cast<int>(rect.width() * percentage);
QRect progressRect = rect;
progressRect.setWidth(progressWidth);
// draw the blue progress bar
// attention: we use the qApp->palette here, as the option.palette depends on option.state
// i.e. the blue bar would become gray if the parent does not have the focus
painter->fillRect(progressRect, qApp->palette().brush(QPalette::Highlight));
// draw a transparent line at the bottom of the cell to for a subtle separation of rows
painter->fillRect(rect.x(), rect.bottom(), rect.width(), 1,
isDarkMode ? QColor(0, 0, 0, 32) : QColor(0, 0, 0, 32));
// Now we must draw the progress text
QString text = QString("%1%").arg(progress);
QRect leftRect = QRect(rect.left(), rect.top(), progressWidth, rect.height());
QRect rightRect =
QRect(rect.left() + progressWidth, rect.top(), rect.right() - progressWidth, rect.height());
// Draw highlighted text over filled area
// HighlightedText text is always white
painter->setClipRect(leftRect);
painter->setPen(option.palette.color(QPalette::HighlightedText));
painter->drawText(rect, Qt::AlignCenter, text);
// Draw normal text over unfilled area
// Text is white in dark mode und black in light mode
painter->setClipRect(rightRect);
painter->setPen(option.palette.color(QPalette::Text));
painter->drawText(rect, Qt::AlignCenter, text);
// As the default hilighting would have the same color as our progress bar
// we do our own hilight indication here.
// We draw 2 rectangles at top and bottom of the cell 3 pixels high (scaled with scaling factor)
if (option.state & QStyle::State_Selected)
{
int selectionIdent = scaling * 3.0;
QRect rectTop = rect;
rectTop.setHeight(selectionIdent);
QRect rectBottom = rectTop;
rectBottom.translate(0, option.rect.height() - selectionIdent);
QColor colorSelection = option.palette.color(QPalette::Highlight);
painter->fillRect(rectTop, colorSelection);
painter->fillRect(rectBottom, colorSelection);
}
painter->restore();
}
}
};
Namespace for the ADTF UI SDK.
Definition adtfui_pkg.h:13

Text Lightness

item_view_themed_text_lightness.h

#include <QApplication>
#include <QStyledItemDelegate>
#include <QPainter>
using namespace adtf::ui;
class ItemViewThemedTextLightness : public QStyledItemDelegate
{
public:
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
{
QStyleOptionViewItem opt(option);
initStyleOption(&opt, index);
const QColor color = QColor(opt.palette.color(QPalette::Text));
if (QApplication::palette().color(QPalette::Window).lightness() < 127)
{
opt.palette.setColor(QPalette::Text, color.lighter(120));
}
else
{
opt.palette.setColor(QPalette::Text, color.darker(120));
}
QApplication::style()->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
}
};

Color Table Model

color_tree_model.h

#ifndef COLOR_TREE_MODEL_H
#define COLOR_TREE_MODEL_H
#include <QAbstractItemModel>
#include <QColor>
#include "color_tree_item.h"
class ColorTreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit ColorTreeModel(QObject* parent = nullptr);
~ColorTreeModel();
QVariant data(const QModelIndex& index, int role) const override;
bool setData(const QModelIndex& index, const QVariant& value, int role);
Qt::ItemFlags flags(const QModelIndex& index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
bool isDarkMode() const;
void setupModelData();
private:
ColorTreeItem* getItem(const QModelIndex& index) const;
ColorTreeItem* m_rootItem;
};
#endif // COLOR_TREE_MODEL_H

color_tree_model.cpp

#include "color_tree_model.h"
#include <qapplication.h>
#include <qpalette.h>
using namespace adtf::ui;
ColorTreeModel::ColorTreeModel(QObject* parent): QAbstractItemModel(parent), m_rootItem(0)
{
setupModelData();
}
ColorTreeModel::~ColorTreeModel()
{
delete m_rootItem;
}
void ColorTreeModel::setupModelData()
{
QVector<QVariant> rootData = {"Name", "Progress", "Value"};
m_rootItem = new ColorTreeItem(rootData);
//
// There are some SVG icons available in XSystem for general purpose...
// Just look at the ThemedIcon::eThemedIcon enum for an overview
//
// If you create your own icons you will notice that some icons looking good in
// light mode, will not look good in dark mode depending on the used colors
//
// This is where the create_themed_icon() function can help.
//
// As a default this function provides icons with a custom factory,
// that inverts the lightness of all colors when using dark mode
//
// Attention: create_themed_icon() works only for SVG (Tiny 1.2) based icons!
//
// If you have special colors that should not be modified, or the result of the default
// mapping is not what you wand, you can customize that by creating a custom color mapping
// where you can define what should happen to a specific color.
//
// Example:
//
// cThemedIconColorMapping mapping;
//
// mapping.addColorMapping("#FFFFFF", "#FFFFFF") // white will stay white
// mapping.addColorMapping("#400000", "#800000") // dark blue will get medium blue
//
// Then you can use this color map as second parameter for create_themed_icon()
//
// QIcon myIcon = create_themed_icon(":/youricon.svg", mapping);
//
// By default ThemedIcon uses a special color map used for all XSystem icons.
//
// If you want ThemedIcon to just do a mapping by lightness the you have to pass
// an empty color map:
//
// cThemedIconColorMapping mapping;
// QIcon myIcon = create_themed_icon(":/youricon.svg", mapping);
//
// Before adding new icons, check if above mentioned general purpose icons already included
// in XSystem fit to your needs.
//
// Examples:
//
// QIcon errorIcon = create_themed_icon(eThemedIcon::Status_Error);
//
//
// For getting distiguishable colors for drawing signals or backgrounds of
// Tables or Trees there is a helper function:
//
// QColor get_color(size_t maxColors, size_t index)
//
// It returns a color at index from maxColors easy distiguishable colors.
//
// See code below for usage...
QVector<QMap<int, QVariant>> columnData1(3);
columnData1[0][Qt::DisplayRole] = QString("Node 1 - Icons & Checkboxes");
ColorTreeItem* item = new ColorTreeItem(columnData1);
int l = 0;
constexpr int numRows = 10;
static const auto oLedGreen = create_themed_icon(eThemedIcon::LED_Green);
static const auto oLedRed = create_themed_icon(eThemedIcon::LED_Red);
static const auto oLedYellow = create_themed_icon(eThemedIcon::LED_Green);
static const auto oStatusError = create_themed_icon(eThemedIcon::Status_Error);
static const auto oStatusWarning = create_themed_icon(eThemedIcon::Status_Warning);
for (int row = 0; row < numRows; ++row)
{
QVector<QMap<int, QVariant>> childData(4);
childData[0][Qt::DisplayRole] = QString("Color %1").arg(row + 1);
switch (l++)
{
case 0: childData[0][Qt::DecorationRole] = oLedGreen; break;
case 1: childData[0][Qt::DecorationRole] = oLedYellow; break;
case 2: childData[0][Qt::DecorationRole] = oLedRed; break;
default: childData[0][Qt::DecorationRole] = oLedGreen; break;
}
if (l > 2)
{
l = 0;
}
childData[2][Qt::DisplayRole] = "Cell with alternating text color";
childData[2][Qt::DecorationRole] = (row % 2 == 0) ? oStatusError : oStatusWarning;
childData[2][Qt::ForegroundRole] = get_color(10, row);
childData[2][Qt::CheckStateRole] = Qt::Unchecked;
item->appendChild(new ColorTreeItem(childData, item));
}
m_rootItem->appendChild(item);
QVector<QMap<int, QVariant>> columnData2(3);
columnData2[0][Qt::DisplayRole] = QString("Node 2 - Row Colors");
item = new ColorTreeItem(columnData2);
for (int row = 0; row < numRows; ++row)
{
QVector<QMap<int, QVariant>> childData(4);
childData[0][Qt::DisplayRole] = QString("Color %1").arg(row + 1);
childData[0][Qt::BackgroundRole] = get_color(numRows, row);
childData[1][Qt::UserRole + 1] = row * numRows + numRows;
childData[2][Qt::DisplayRole] = "Cell with alternating background color";
childData[2][Qt::BackgroundRole] = get_color(numRows, row);
item->appendChild(new ColorTreeItem(childData, item));
}
m_rootItem->appendChild(item);
QVector<QMap<int, QVariant>> columnData4(3);
columnData4[0][Qt::DisplayRole] = QString("Node 2 - Row Color (alpha 0.6)");
item = new ColorTreeItem(columnData4);
for (int row = 0; row < numRows; ++row)
{
QColor colorBackground = get_color(numRows, row);
// Set alpha to blend the selected color with the native theme background color
// for better contrast with text.
colorBackground.setAlphaF(0.6);
QVector<QMap<int, QVariant>> childData(4);
childData[0][Qt::DisplayRole] = QString("Color %1").arg(row + 1);
childData[0][Qt::BackgroundRole] = colorBackground;
childData[1][Qt::UserRole + 1] = row * numRows + numRows;
childData[2][Qt::DisplayRole] = "Cell with alternating background color with alpha 0.6";
childData[2][Qt::BackgroundRole] = colorBackground;
item->appendChild(new ColorTreeItem(childData, item));
}
m_rootItem->appendChild(item);
QVector<QMap<int, QVariant>> columnData5(3);
columnData5[0][Qt::DisplayRole] = QString("Node 2 - Row Color (alpha 0.6)");
item = new ColorTreeItem(columnData5);
for (int row = 0; row < numRows; ++row)
{
QColor colorBackground = QColor("#4E79A7");
// Set alpha to blend the selected color with the native theme background color
// for better contrast with text.
colorBackground.setAlphaF(0.6);
QVector<QMap<int, QVariant>> childData(4);
childData[0][Qt::DisplayRole] = QString("Blue");
childData[0][Qt::BackgroundRole] = colorBackground;
childData[1][Qt::UserRole + 1] = row * numRows + numRows;
childData[2][Qt::DisplayRole] = "Cell with blue background color with alpha 0.6";
childData[2][Qt::BackgroundRole] = colorBackground;
item->appendChild(new ColorTreeItem(childData, item));
}
m_rootItem->appendChild(item);
}
int ColorTreeModel::columnCount(const QModelIndex& /*parent*/) const
{
return 3;
}
QVariant ColorTreeModel::data(const QModelIndex& index, int role) const
{
if (!index.isValid())
{
return QVariant();
}
ColorTreeItem* item = getItem(index);
return item->data(index.column(), role);
}
bool ColorTreeModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
if (!index.isValid())
{
return false;
}
ColorTreeItem* item = getItem(index);
if (!item)
{
return false;
}
if (role == Qt::CheckStateRole && index.column() == 2)
{
item->setData(index.column(), role, value);
emit dataChanged(index, index, {Qt::CheckStateRole});
return true;
}
return false;
}
Qt::ItemFlags ColorTreeModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
{
return Qt::NoItemFlags;
}
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate;
}
QVariant ColorTreeModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
return m_rootItem->data(section, Qt::DisplayRole);
}
return QVariant();
}
QModelIndex ColorTreeModel::index(int row, int column, const QModelIndex& parent) const
{
if (!hasIndex(row, column, parent))
{
return QModelIndex();
}
ColorTreeItem* parentItem = getItem(parent);
ColorTreeItem* childItem = parentItem->child(row);
if (childItem)
{
return createIndex(row, column, childItem);
}
return QModelIndex();
}
QModelIndex ColorTreeModel::parent(const QModelIndex& index) const
{
if (!index.isValid())
{
return QModelIndex();
}
ColorTreeItem* childItem = getItem(index);
ColorTreeItem* parentItem = childItem->parentItem();
if (parentItem == m_rootItem || !parentItem)
{
return QModelIndex();
}
return createIndex(parentItem->row(), 0, parentItem);
}
int ColorTreeModel::rowCount(const QModelIndex& parent) const
{
ColorTreeItem* parentItem = getItem(parent);
return parentItem->childCount();
}
ColorTreeItem* ColorTreeModel::getItem(const QModelIndex& index) const
{
if (index.isValid())
{
ColorTreeItem* item = static_cast<ColorTreeItem*>(index.internalPointer());
if (item)
{
return item;
}
}
return m_rootItem;
}
bool ColorTreeModel::isDarkMode() const
{
return QApplication::palette().color(QPalette::Window).lightness() < 127;
}
QIcon create_themed_icon(QString file, cThemedIconColorMapping themedIconColorMapping=cThemedIconColorMapping::GetDefaultColorMapping())
Creates a themed icon from given svg file with color mapping.
QColor get_color(size_t maxColors, size_t colorIndex)
Get tableau 10 colors. If maxColors is greater or equal to 20 it uses tableau 20 colors.

Color Tree Model

color_tree_item.h

#ifndef COLOR_TREE_ITEM_H
#define COLOR_TREE_ITEM_H
#include <QVariant>
#include <QVector>
class ColorTreeItem
{
public:
explicit ColorTreeItem(const QVector<QMap<int, QVariant>>& data, ColorTreeItem* parent = nullptr);
explicit ColorTreeItem(const QVector<QVariant>& data, ColorTreeItem* parent = nullptr);
~ColorTreeItem();
void appendChild(ColorTreeItem* child);
ColorTreeItem* child(int row);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
QVariant data(int column, int role) const;
bool setData(int column, int role, const QVariant& value);
int row() const;
ColorTreeItem* parentItem();
private:
QVector<ColorTreeItem*> m_childItems;
QVector<QMap<int, QVariant>> m_itemData;
ColorTreeItem* m_parentItem;
};
#endif // COLOR_TREE_ITEM_H

color_tree_item.cpp

#include "color_tree_item.h"
ColorTreeItem::ColorTreeItem(const QVector<QMap<int, QVariant>>& data, ColorTreeItem* parent):
m_itemData(data), m_parentItem(parent)
{
}
ColorTreeItem::ColorTreeItem(const QVector<QVariant>& data, ColorTreeItem* parent): m_parentItem(parent)
{
for (const QVariant& value : data)
{
QMap<int, QVariant> roleMap;
roleMap[Qt::DisplayRole] = value;
m_itemData.append(roleMap);
}
}
ColorTreeItem::~ColorTreeItem()
{
qDeleteAll(m_childItems);
}
void ColorTreeItem::appendChild(ColorTreeItem* child)
{
m_childItems.append(child);
}
ColorTreeItem* ColorTreeItem::child(int row)
{
if (row < 0 || row >= m_childItems.size())
{
return nullptr;
}
return m_childItems.at(row);
}
int ColorTreeItem::childCount() const
{
return m_childItems.count();
}
int ColorTreeItem::columnCount() const
{
return m_itemData.count();
}
QVariant ColorTreeItem::data(int column) const
{
return data(column, Qt::DisplayRole);
}
QVariant ColorTreeItem::data(int column, int role) const
{
if (column < 0 || column >= m_itemData.size())
{
return QVariant();
}
return m_itemData.at(column).value(role, QVariant());
}
bool ColorTreeItem::setData(int column, int role, const QVariant& value)
{
if (column < 0 || column >= m_itemData.size())
{
return false;
}
m_itemData[column][role] = value;
return true;
}
int ColorTreeItem::row() const
{
if (m_parentItem)
{
return m_parentItem->m_childItems.indexOf(const_cast<ColorTreeItem*>(this));
}
return 0;
}
ColorTreeItem* ColorTreeItem::parentItem()
{
return m_parentItem;
}

Test Dialog

test_dialog.h

/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#pragma once
#include <QDialog>
#include <ui_demo_filter.h>
class cTestDialog : public QDialog
{
Q_OBJECT
public:
cTestDialog(QWidget* pParent);
Ui_TestUI ui;
};

test_dialog.cpp

/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#include <test_dialog.h>
#include <qcheckbox.h>
#include <qwidget.h>
#include "color_table_model.h"
#include "color_tree_model.h"
#include "progress_bar_delegate.h"
#include "item_view_themed_text_lightness.h"
cTestDialog::cTestDialog(QWidget* pParent): QDialog(pParent, Qt::Dialog | Qt::WindowCloseButtonHint)
{
ui.setupUi(this);
setSizeGripEnabled(true);
ui.tabWidget->tabBar()->setTabButton(0, QTabBar::ButtonPosition::LeftSide, new QCheckBox());
ui.tabWidget_2->tabBar()->setTabButton(0, QTabBar::ButtonPosition::LeftSide, new QCheckBox());
ColorTableModel* model = new ColorTableModel();
double scaling = ui.tableView->font().pointSizeF() / 10.0;
ui.tableView->setModel(model);
ui.tableView->verticalHeader()->setFixedWidth(100 * scaling);
ui.tableView->setColumnWidth(0, 200 * scaling);
ui.tableView->setColumnWidth(1, 200 * scaling);
ColorTreeModel* treeModel = new ColorTreeModel();
ui.treeView->setModel(treeModel);
ui.treeView->setAlternatingRowColors(true);
ui.treeView->setItemDelegateForColumn(0, new ItemViewThemedTextLightness());
ui.treeView->setItemDelegateForColumn(1, new ProgressBarDelegate());
ui.treeView->setItemDelegateForColumn(2, new ItemViewThemedTextLightness());
ui.treeView->setColumnWidth(0, 230 * scaling);
ui.treeView->setColumnWidth(1, 250 * scaling);
ui.treeView->setColumnWidth(2, 200 * scaling);
}

UI Filter

qt_ui_demo_filter.h

/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#pragma once
#include <adtffiltersdk/adtf_filtersdk.h>
#include <adtffiltersdk/graph_object.h>
#include <adtffiltersdk/runner_fallback.h>
#include <adtfui/adtf_ui.h>
#include <QWidget>
class cQtUiDemoWidget;
#ifndef ADTF_EXAMPLES_CID
#define ADTF_EXAMPLES_CID ".local.cid"
#endif
class cQtUiDemoFilter : public adtf::ui::cQtUIFilter
{
public:
ADTF_CLASS_ID_NAME(cQtUiDemoFilter, "qt_ui_demo.ui_filter" ADTF_EXAMPLES_CID, "Demo Qt5 UI");
ADTF_CLASS_DEPENDENCIES(REQUIRE_INTERFACE(adtf::ui::IQtXSystem));
public:
cQtUiDemoFilter();
~cQtUiDemoFilter() override;
tResult Init(tInitStage eStage) override;
tResult Start() override;
tResult Stop() override;
QWidget* CreateView() override;
void ReleaseView() override;
cQtUiDemoWidget* m_pWidget;
};
virtual QWidget * CreateView()=0
virtual void ReleaseView()=0
tResult Init(typename FILTERBASECLASS::tInitStage eStage) override
Definition qt_ui_filter.h:283
Interface definition for the ADTF XSystem based on Qt. Use this interface to create your own displays...
Definition qtxsystem_intf.h:385
v0::qt_ui_filter< adtf::filter::cFilter, cQtWindow > cQtUIFilter
Definition qt_ui_filter.h:382

qt_ui_demo_filter.cpp

/*
* This file depends on Qt which is licensed under LGPLv3.
* See ADTF_DIR/3rdparty/qt5 and doc/license for detailed information.
*/
#include "qt_ui_demo_filter.h"
#include <ui_demo_filter.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <QtWidgets/qshortcut.h>
#include <QDebug>
#include "color_table_model.h"
#include "color_tree_model.h"
#include "progress_bar_delegate.h"
#include "test_dialog.h"
#include "item_view_themed_text_lightness.h"
#include "qt_ui_demo_widget.h"
ADTF_PLUGIN("Qt5 UI Demo Plugin", cQtUiDemoFilter)
cQtUiDemoFilter::cQtUiDemoFilter()
{
// sets a short description for the component
SetDescription("Use this UI filter to show how to customize UI with Qt in Qt5 ADTF XSystem UI Service.");
// set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/html/page_demo_qt5_ui.html");
}
cQtUiDemoFilter::~cQtUiDemoFilter() = default;
tResult cQtUiDemoFilter::Init(tInitStage eStage)
{
RETURN_IF_FAILED(adtf::ui::cQtUIFilter::Init(eStage))
RETURN_NOERROR;
}
tResult cQtUiDemoFilter::Start()
{
RETURN_IF_FAILED(adtf::ui::cQtUIFilter::Start());
RETURN_NOERROR;
}
tResult cQtUiDemoFilter::Stop()
{
return adtf::ui::cQtUIFilter::Stop();
}
QWidget* cQtUiDemoFilter::CreateView()
{
m_pWidget = new cQtUiDemoWidget();
m_pWidget->setObjectName("qt_ui_demo_widget");
return m_pWidget;
}
void cQtUiDemoFilter::ReleaseView()
{
delete m_pWidget;
m_pWidget = nullptr;
}

demo_filter.ui

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TestUI</class>
<widget class="QWidget" name="TestUI">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>767</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>600</width>
<height>480</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>4000</width>
<height>2000</height>
</size>
</property>
<property name="windowTitle">
<string>UI Controls Test</string>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="sizeGripEnabled" stdset="0">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>800</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="autoFillBackground">
<bool>false</bool>
</property>
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Triangular</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="documentMode">
<bool>false</bool>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Vertical tab with close button and check box</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item row="4" column="1">
<widget class="QTabWidget" name="tabWidget_3">
<property name="tabPosition">
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_6">
<attribute name="title">
<string>Tab 2</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_5">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="6" column="0">
<widget class="QTabWidget" name="tabWidget_6">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="tabPosition">
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="QWidget" name="tab_11">
<attribute name="title">
<string>Tab 1</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_3">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_12">
<attribute name="title">
<string>Tab 2</string>
</attribute>
</widget>
</widget>
</item>
<item row="4" column="0">
<widget class="QTabWidget" name="tabWidget_4">
<property name="minimumSize">
<size>
<width>400</width>
<height>0</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>Tab for horizontal scroll button testing</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="radioButton_2">
<property name="text">
<string>RadioButton</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_8">
<attribute name="title">
<string>Tab with a longer name</string>
</attribute>
</widget>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="horizontalSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QProgressBar" name="progressBar">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="value">
<number>48</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QTabWidget" name="tabWidget_5">
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>1</number>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="QWidget" name="tab_9">
<attribute name="title">
<string>Tab 1</string>
</attribute>
</widget>
<widget class="QWidget" name="tab_10">
<attribute name="title">
<string>Tab 2</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>CheckBox</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="spinBox">
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tab widget &quot;North&quot;</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Tab widget &quot;South&quot;</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="comboBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Tab widget &quot;West&quot;</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Tab widget &quot;East&quot;</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Vertical tab with close button</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<property name="tabsClosable">
<bool>true</bool>
</property>
<widget class="QWidget" name="tab">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title">
<string>TableView</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QTableView" name="tableView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>TreeView</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
<number>8</number>
</property>
<property name="topMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>8</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QTreeView" name="treeView">
<attribute name="headerCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>