📄 toolbar.cc
字号:
/** @file ToolBar class, ancestor of QToolBar. This toolbar can handle only buttons derived from ToolButton class (any generic QWidget can be inserted, but the widget must then handle clicks, etc ... by itself) @author Martin Petricek*/#include "toolbar.h"#include "toolbutton.h"#include <QString>#include <QMainWindow>namespace gui {/** Same constructor as QToolBar @param label Caption of toolbar @param mainWindow Main window in which toolbar will be managed */ToolBar::ToolBar(const QString &label,QMainWindow *mainWindow) : QToolBar(label,mainWindow) { //Set reasonable default currentButtonSize=22;}/** Add button to toolbar and link slots, so clicks from buttons are passed along with button ID to the application @param qb Button to add to this toolbar */void ToolBar::addButton(ToolButton *qb) { QObject::connect(qb,SIGNAL(clicked(ToolButton*)),this,SLOT(slotClicked(ToolButton*))); QObject::connect(qb,SIGNAL(helpText(const QString&)),this,SLOT(receiveHelpText(const QString&))); QObject::connect(this,SIGNAL(setNewSize(int)),qb,SLOT(setSizes(int))); qb->setSizes(currentButtonSize); addWidget(qb);}/** Set new size of button in toolbar. Button is always square, function have no effect on other widgets in toolbar. @param newSize new size of toolbar buttons*/void ToolBar::setButtonSizes(int newSize) { currentButtonSize=newSize; if (currentButtonSize<MIN_TOOLBUTTON_SIZE) currentButtonSize=MIN_TOOLBUTTON_SIZE; if (currentButtonSize>MAX_TOOLBUTTON_SIZE) currentButtonSize=MAX_TOOLBUTTON_SIZE; emit setNewSize(currentButtonSize);}/** Slot that will emit clicked with pointer to button @param id Pointer to button that emitted the click*/void ToolBar::slotClicked(ToolButton *id) { emit itemClicked(id);}/** Signal called when receiving help message. Forward the message via helpText @param message Help message*/void ToolBar::receiveHelpText(const QString &message) { emit helpText(message);}} // namespace gui
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -