Importing the SARibbon Library¶
- ✅ Static embedding: Just copy
SARibbon.h+SARibbon.cppto integrate - ✅ CMake find_package: Build & install, then
find_package(SARibbonBar)to link dynamic library - ✅ qmake pri inclusion: One-line
importSARibbonBarLib.pricompletes integration - ✅ Optional QWindowKit: Enable borderless window & Windows 11 Snap Layout via preprocessor macros
- ✅ Static lib resource init:
Q_INIT_RESOURCEauto-loads resources when built as static library
Direct Inclusion¶
Direct inclusion is the simplest integration method. Just add src/SARibbon.h and src/SARibbon.cpp to your project. By default, QWindowKit (qwk) is not enabled. If you need to enable it, do the following:
-
Add preprocessor macros
-
Set
SARIBBON_USE_3RDPARTY_FRAMELESSHELPERto 1 - Set
SARIBBON_ENABLE_SNAP_LAYOUTto 1
If using qmake, add the following to your .pro file:
1 2 3 | |
If using a Visual Studio project:
- Right-click the project → Properties
- Select C/C++ → Preprocessor
- Add the macros under Preprocessor Definitions
Bringing SARibbon into a CMake project¶
- Build and install SARibbon with CMake first.
- In your own
CMakeLists.txt:
1. Tell CMake where SARibbon was installed¶
Point SARibbonBar_DIR to the folder that contains SARibbonBarConfig.cmake, e.g.
1 | |
2. Load the package¶
1 | |
This fills the variables SARibbonBar_INCLUDE_DIRS, compile definitions, etc.
3. Link your target¶
1 | |
That is all that is required.
Bringing SARibbon into a qmake project¶
Warning
Qt 6 officially deprecated qmake; SARibbon may drop qmake support in a future release.
After you built SARibbon with qmake you will find a folder
bin_qt{version}_{MSVC|GNU}_x{32|64} that contains the libraries and DLLs.
A convenience pri file, importSARibbonBarLib.pri, automatically adds these to your project.
Step-by-step:
1. Copy the source tree¶
Create a 3rdparty folder inside your project and copy the whole SARibbon directory into it.
The repository already contains several .pri files that make inclusion trivial.
importSARibbonBarLib.priis the entry point; adapt it if you change the directory layout.
2. Edit common.pri¶
Open 3rdparty/SARibbon/common.pri and uncomment the options you need:
1 2 3 4 5 6 7 8 | |
3. Include the pri file¶
In your .pro file add:
1 | |
Typical resulting tree:
1 2 3 4 5 6 7 8 | |
The three pri files above are the only ones you normally touch.
Public pre-processor macros¶
When you consume a pre-built SARibbon library (especially with MSVC) you must define the same macros that were used while building it:
| Macro | Value | Meaning |
|---|---|---|
SARIBBON_USE_3RDPARTY_FRAMELESSHELPER |
1/0 | Built with/without QWindowKit |
SARIBBON_ENABLE_SNAP_LAYOUT |
1/0 | Snap-layout support (only if previous = 1) |
Enabling QWindowKit in a static inclusion¶
Static inclusion = add SARibbon.h + SARibbon.cpp directly to your project
(QWindowKit is off by default here).
To turn it on:
-
Define the macros
SARIBBON_USE_3RDPARTY_FRAMELESSHELPER=1
SARIBBON_ENABLE_SNAP_LAYOUT=1(optional) -
qmake example:
1 2 | |
- Visual Studio example:
Project → Properties → C/C++ → Preprocessor →
Preprocessor Definitions → add the two macros above.
Rebuild—QWindowKit support is now active even in the single-header/static mode.
Complete CMakeLists.txt Example for Direct Inclusion¶
Below is a complete CMakeLists.txt configuration for directly embedding SARibbon.h and SARibbon.cpp into your project (referenced from example/StaticExample):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | |
Tip
Direct inclusion is the simplest approach, suitable for quick start. For larger projects or when sharing SARibbon across multiple projects, it is recommended to build as a dynamic library and include via find_package.