Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Toolbars in the main Qt window

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report