Qt QtitanRibbon HelloWorld

2021-11-09  本文已影响0人  百里有声

WPF 下有Telerik可以很方便的实现Office的样式。习惯了Office2007下蓝色的调调,所以找了QtitanRibbon进行Qt下的开发

可参考的文章很少,对于一个Qt新手很是折磨,琢磨调试了两天总算运行起来的。

只针对入门者,觉得有帮助可以点一个赞。

记录如下:

开发环境:

image.png
  1. Qt中只安装了mingw 64相关的可选项


    image.png
  2. Qt安装完成后,定义一下环境变量


    image.png
  3. QtitanRibbonInstaller5.9.0_mingw 安装过程中会要求定位qmake路径,先正确选择


    image.png

代码结构

#include <QtitanRibbon.h>
#include <QApplication>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);   
    
    RibbonBar* m_dlgRibbonBar = new RibbonBar();
    m_dlgRibbonBar->addPage(QObject::tr("Home"));
    
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(m_dlgRibbonBar);

    QWidget *window = new QWidget;
    window->setWindowTitle("Hello Titan");
    window->setLayout(layout);
    window->show();
    return app.exec();
}
######################################################################
# Automatically generated by qmake (3.1) 
######################################################################

TEMPLATE = app
TARGET = HelloTitan
INCLUDEPATH += .

# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

# Input
SOURCES += HelloTitan.cpp

######################################################################
# Automatically generated by qmake (3.1) 
######################################################################

TEMPLATE = app
TARGET = HelloTitan
INCLUDEPATH += .
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
include(C:/Qt/Developer Machines/QtitanRibbon5.9.0/src/shared/qtitanribbon.pri)
# You can make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# Please consult the documentation of the deprecated API in order to know
# how to port your code away from it.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

# Input
SOURCES += HelloTitan.cpp
LIBS += -L$$QTITAN_LIB_PATH/ -llibQtitanRibbon5 -llibQtitanBase1

#include <QtitanRibbon.h>
#include <QApplication>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);   

    Office2016Style* style = new Office2016Style();
    style->setTheme(Office2016Style::Colorful);
    qApp->setStyle(style);
    
    RibbonBar* m_dlgRibbonBar = new RibbonBar();
    m_dlgRibbonBar->addPage(QObject::tr("Home"));
    
    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(m_dlgRibbonBar);

    QWidget *window = new QWidget;
    window->setWindowTitle("Hello Titan");
    window->setLayout(layout);
    window->show();
    return app.exec();
}
上一篇 下一篇

猜你喜欢

热点阅读