美文网首页
Qt QtitanRibbon HelloWorld

Qt QtitanRibbon HelloWorld

作者: 百里有声 | 来源:发表于2021-11-09 11:43 被阅读0次

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

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

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

记录如下:

开发环境:

  • qt-opensource-windows-x86-5.14.2
  • QtitanRibbonInstaller5.9.0_mingw
image.png
  1. Qt中只安装了mingw 64相关的可选项


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


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


    image.png

代码结构

  • 定义文件 HelloTitan.cpp


    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();
}
  • 在当前目录打开 cmd ,并运行 qmke -project 生成 HelloTitan.pro


    image.png
  • HelloTitan.pro文件的内容为

######################################################################
# 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

  • 修改HelloTitan.pro添加相关引用
######################################################################
# 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

  • 生成Make 文件


    image.png
    image.png
  • 编译


    image.png
  • 运行 release 下的文件报错


    image.png
  • 将HelloTitan.exe拷贝到 QtitanRibbon的bin目录就行了


    image.png
  • 修改HelloTitan.cpp 改变样式
#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();
}
  • 运行效果


    image.png

相关文章

  • Qt QtitanRibbon HelloWorld

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

  • 15--Qt Quick 概览

    标签(空格分隔): Qt 项目中目录各个文件说明 helloWorld.pro 该文件是项目文件,其中包含了项目相...

  • ubuntu发布qt程序

    一个简单的QT程序 一个简单的程序,并没有列出pro文件,目录为helloworld。 #include #in...

  • QT-01HelloWorld(Button)

    创建一个程序 实例化一个按钮 添加按钮监听 源程序 /* 应用程序抽象类 */ #include /*窗口类*/ ...

  • 01-C开发基础实战

    day01-C语言概述 1.编写helloworld.c 2.Windows下载QT之后,在文件夹的tools下会...

  • 如何打包QT的应用程序

    第一步 将文件编译为release版 第二步 在新生成的build-HelloWorld-Desktop_Qt_5...

  • C++框架 之Qt的窗口部件系统的详解

    第一部分概述 第一次建立helloworld程序时,曾看到Qt Creator提供的默认基类只有QMainWind...

  • 无标题文章

    helloworld helloworld helloworld helloworld helloworld he...

  • 2019-01-05

    HelloWorld HelloWorld HelloWorld HelloWorld HelloWorld He...

  • CMake —— 获取环境变量

    $ENV{HELLOWORLD} 注意事项:set(HELLOWORLD $ENV{HELLOWORLD}) 这是...

网友评论

      本文标题:Qt QtitanRibbon HelloWorld

      本文链接:https://www.haomeiwen.com/subject/lhymzltx.html