Set application icon and show logo in QWidget style
parent
277d253e09
commit
6d3e329a6a
|
@ -24,6 +24,7 @@ find_package(Qt5 ${QT_MIN_VERSION} CONFIG
|
|||
Test
|
||||
OPTIONAL_COMPONENTS
|
||||
Widgets
|
||||
Svg
|
||||
Quick
|
||||
)
|
||||
find_package(Qt5QuickControls2 EXACT ${Qt5Core_VERSION})
|
||||
|
@ -56,7 +57,7 @@ add_subdirectory(src)
|
|||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
||||
if(Qt5Widgets_FOUND)
|
||||
if(Qt5Widgets_FOUND AND Qt5Svg_FOUND)
|
||||
add_subdirectory(demo)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ add_custom_command(
|
|||
add_custom_target(rust_target DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a")
|
||||
|
||||
list(APPEND DemoLibs "${CMAKE_CURRENT_SOURCE_DIR}/rust/${RUST_TARGET_DIR}/librust.a")
|
||||
list(APPEND DemoLibs Qt5::Widgets)
|
||||
list(APPEND DemoLibs Qt5::Widgets Qt5::Svg)
|
||||
if (Qt5Quick_FOUND)
|
||||
list(APPEND DemoLibs Qt5::Quick)
|
||||
endif()
|
||||
|
|
|
@ -25,11 +25,13 @@
|
|||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListView>
|
||||
#include <QTableView>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStringListModel>
|
||||
#include <QStyleFactory>
|
||||
#include <QSvgRenderer>
|
||||
#include <QSvgWidget>
|
||||
#include <QTabWidget>
|
||||
#include <QTableView>
|
||||
#include <QTreeView>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWindow>
|
||||
|
@ -153,9 +155,16 @@ QWidget* createStyleTab(Models* models, QWidget* tabs, QComboBox* box,
|
|||
}
|
||||
};
|
||||
box->connect(box, &QComboBox::currentTextChanged, box, f);
|
||||
// box->setCurrentText(style);
|
||||
// f(style);
|
||||
return box;
|
||||
|
||||
QSvgWidget* logo = new QSvgWidget("/home/oever/src/rust_qt_binding_generator/logo.svg");
|
||||
logo->setFixedSize(logo->renderer()->defaultSize());
|
||||
|
||||
QWidget* tab = new QWidget;
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
layout->addWidget(box);
|
||||
layout->addWidget(logo);
|
||||
tab->setLayout(layout);
|
||||
return tab;
|
||||
}
|
||||
|
||||
QWidget* createObjectTab(Models* models) {
|
||||
|
@ -290,6 +299,7 @@ void createWidgets(Models* models, const QString& initialStyle,
|
|||
int main (int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setWindowIcon(QIcon(":/logo.svg"));
|
||||
|
||||
#ifdef QT_QUICK_LIB
|
||||
qmlRegisterType<QSortFilterProxyModel>("org.qtproject.example", 1, 0, "SortFilterProxyModel");
|
||||
|
|
Loading…
Reference in New Issue