Get the App
SLTechnology News&Howtos  ›  Servers  › 

Toolbars in the main Qt window

Shulou Source: shulou.com Published: 2022-06-02 19:27:57 09月30日 Update

Toolbar class

QToolBar

Shortcut item

QAciton

QToolBar* tb = addToolBar ("ToolBar"); / / addToolBar is a member function of the Qt main window, create a toolbar in the main window and get the pointer QAciton * action = new QAciton (", NULL); / / create a shortcut action- > setToolTip (" Open ") / / display open action- > setIcon (QIcon (": / Res/pic/open.png")) when the mouse is moved here; / / set the shortcut icon in the resource file / / path tb- > addAction (action); / / add the shortcut to the toolbar

1. Key member functions of QToolBar

-void setFloatable (bool floatable) / / sets whether it can be suspended in the created toolbar.

-void setMoveable (bool moveable) / / Settings toolbar cannot be moved

-void setIconSize (const QSize& iconSize) / / s sets the size of each shortcut icon in the toolbar

2. Any QWidget component can be added to QToolBar.

QToolBar * tb = addToolBar ("ToolBar"); QPushButton * b = new QPushButton ("Button"); QLabel * l = new QLable ("Label"); QLineEdit * e = new QLineEdit (); tb- > addWidget (b); tb- > addWidget (l); tb- > addWidget (e)

3. Toolbar application

This- > resize (800,480); QToolBar * tb = this- > addToolBar ("ToolBar"); QAction * action = new QAction ("", NULL); action- > setToolTip ("Open"); / / set the word action- > setIcon (QIcon (": / Res/open.png") that appears when the mouse moves over the shortcut /: indicates that the added picture is under the resource file, / Res is the prefix tb- > addAction (action) where the open.png is located in the resource file; / / add shortcut items to the toolbar tb- > setIconSize (QSize (100,100)); / / set the shortcut icon size tb- > setFloatable (false) in the toolbar; / / set the toolbar cannot be docked in another location tb- > setMovable (false) / / the Settings toolbar cannot be moved.

Tags: Tools toolbars moves icons files resources functions size members mouse location keys prefixes pictures locations pointers components paths Zhongchuang Zhongshi Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Apple MySQL NVidia