Using Qt in Sandbox comes with a few guidelines and restrictions
The Sandbox code contains a large library of reusable components, such as Qt Widgets, various helpers, and platform abstraction tools. All of these extensions can be found in the EditorCommon project, in particular, EditorCommon/Controls and EditorCommon/Dialogs.
The goal is to provide a more powerful framework and a unified way to solve UI problems across the whole tool. By using these you will get a better UI, a faster result, and help the Sandbox look and feel consistent. Feel free to call and extend this framework as much as possible.
You should always use the following classes instead of the original ones. Failure to do this should be caught during code review. Only by using the right set of classes everywhere can we ensure consistency throughout the Sandbox.
Qt Class | Replacement | Reason |
---|---|---|
QDialog | CEditorDialog | Styling and personalization can only be achieved like this. Will also handle more things such as platform-specific placement of buttons etc. |
QComboBox | QMenuComboBox | QComboBox has several bugs and many issues with styling. We opted for a full replacement with a similar API. Please do not use QComboBox. |
QIcon | CryIcon | Unified styling, icon color tinting etc. See Theme, Styling, and Colors Once constructed a CryIcon may safely be stored in a QIcon variable, so this is fine: QIcon foo = CryIcon("bar"); |
QPixmap | CryIcon.pixmap() | If you are using a pixmap that should behave like an icon, prefer using CryIcon.pixmap() to get the benefits of styling and tinting. |
QMessageBox | CQuestionDialog | Styling and unification. Our CQuestionDialog dialogs look amazing, just use them! |
QPalette | QSS Stylesheet | QPalette is deprecated as we use style sheets. See Theme, Styling, and Colors |
QLineEdit | QNumericBox | For numeric fields only: Implements many advanced behaviors and interactions. |
It is recommended to use the following classes instead of the original ones.
Qt Class | Replacement | Reason |
---|---|---|
QTreeView | QAdvancedTreeView | Provides extra generic functionality. Handles Layout concerns. |
QStyledItemDelegate | QAdvancedItemDelegate | Provides extra generic functionality, such as drag-checking, or displaying a different icon than a checkbox. |
QMimeData | CDragDropData | Provides extra generic functionality. Drag-tooltip, and a much easier interface to drag complex types within the application. |
All the reusable widgets and Qt helpers are available in the EditorCommon package. Take a look at the source code to discover more useful classes!
Another set of extensions to Qt is the ItemModel Framework which is described in a dedicated page.
Component | Description |
---|---|
QControls.h | Contains a lot of fairly simple reusable widgets and UI components. |
QMenuLabelSeparator | Menu separator with a label. |
QLoading | Rotating icon to symbolize loading/processing. |
QEditableComboBox | ComboBox with editable content through a LineEdit. |
QSearchBox | Unified search box, do not use QLineEdit for this. |
CDynamicPopupMenu / CMenuBuilder | Abstracted menu system used to build complex dynamic menus without depending on Qt. |
QCollapsibleFrame | UI component to group widgets has a title, can be collapsed. |
QFullScreenWidget | Enables any widget to react to full screen (F11) command and go fullscreen. |
QTrackingTooltip | Very useful to denote contextual information in particular for drag-operations. This should be used liberally as it makes the UX much more predictable and drag-features are some of the hardest ones to discover. |
QPopupWidget | Creates a resizable popup window that can embed any widget. Useful for popup tools, such as the notification center and other tray area widgets. |