MyTetra Share
Делитесь знаниями!
Qt: как использовать стандартные иконки
Время создания: 27.06.2016 20:36
Раздел: Компьютер - Программирование - Язык C++ (Си++) - Библиотека Qt - Графика
Запись: xintrea/mytetra_syncro/master/base/1437431865x8x8s4dkb2/text.html на raw.github.com

В библиотеку Qt заложено много стандартных иконок. Их можно использовать при оформлении кнопок.


К сожалению, прямого метода установить системную иконку на кнопку в Qt даже в версии 5.4.2 нет. Но можно воспользоваться одним трюком:


QPushButton *pushButtonHelp=new QPushButton(this);

QCommonStyle style;

pushButtonHelp->setIcon(style.standardIcon(QStyle::SP_MessageBoxQuestion));


Возможные значения стандартных иконок устанавливаются через следующее перечисление:


enum QStyle::StandardPixmap

Это перечисление описывает доступные стандартные иконки. О внешнем виде иконки можно судить по следующему описанию:


Constant

Value

Description

QStyle::SP_TitleBarMinButton

1

Minimize button on title bars (e.g., in QMdiSubWindow ).

QStyle::SP_TitleBarMenuButton

0

Menu button on a title bar.

QStyle::SP_TitleBarMaxButton

2

Maximize button on title bars.

QStyle::SP_TitleBarCloseButton

3

Close button on title bars.

QStyle::SP_TitleBarNormalButton

4

Normal (restore) button on title bars.

QStyle::SP_TitleBarShadeButton

5

Shade button on title bars.

QStyle::SP_TitleBarUnshadeButton

6

Unshade button on title bars.

QStyle::SP_TitleBarContextHelpButton

7

The Context help button on title bars.

QStyle::SP_MessageBoxInformation

9

The "information" icon.

QStyle::SP_MessageBoxWarning

10

The "warning" icon.

QStyle::SP_MessageBoxCritical

11

The "critical" icon.

QStyle::SP_MessageBoxQuestion

12

The "question" icon.

QStyle::SP_DesktopIcon

13

The "desktop" icon.

QStyle::SP_TrashIcon

14

The "trash" icon.

QStyle::SP_ComputerIcon

15

The "My computer" icon.

QStyle::SP_DriveFDIcon

16

The floppy icon.

QStyle::SP_DriveHDIcon

17

The harddrive icon.

QStyle::SP_DriveCDIcon

18

The CD icon.

QStyle::SP_DriveDVDIcon

19

The DVD icon.

QStyle::SP_DriveNetIcon

20

The network icon.

QStyle::SP_DirHomeIcon

56

The home directory icon.

QStyle::SP_DirOpenIcon

21

The open directory icon.

QStyle::SP_DirClosedIcon

22

The closed directory icon.

QStyle::SP_DirIcon

38

The directory icon.

QStyle::SP_DirLinkIcon

23

The link to directory icon.

QStyle::SP_DirLinkOpenIcon

24

The link to open directory icon.

QStyle::SP_FileIcon

25

The file icon.

QStyle::SP_FileLinkIcon

26

The link to file icon.

QStyle::SP_FileDialogStart

29

The "start" icon in a file dialog.

QStyle::SP_FileDialogEnd

30

The "end" icon in a file dialog.

QStyle::SP_FileDialogToParent

31

The "parent directory" icon in a file dialog.

QStyle::SP_FileDialogNewFolder

32

The "create new folder" icon in a file dialog.

QStyle::SP_FileDialogDetailedView

33

The detailed view icon in a file dialog.

QStyle::SP_FileDialogInfoView

34

The file info icon in a file dialog.

QStyle::SP_FileDialogContentsView

35

The contents view icon in a file dialog.

QStyle::SP_FileDialogListView

36

The list view icon in a file dialog.

QStyle::SP_FileDialogBack

37

The back arrow in a file dialog.

QStyle::SP_DockWidgetCloseButton

8

Close button on dock windows (see also QDockWidget ).

QStyle::SP_ToolBarHorizontalExtensionButton

27

Extension button for horizontal toolbars.

QStyle::SP_ToolBarVerticalExtensionButton

28

Extension button for vertical toolbars.

QStyle::SP_DialogOkButton

39

Icon for a standard OK button in a QDialogButtonBox .

QStyle::SP_DialogCancelButton

40

Icon for a standard Cancel button in a QDialogButtonBox .

QStyle::SP_DialogHelpButton

41

Icon for a standard Help button in a QDialogButtonBox .

QStyle::SP_DialogOpenButton

42

Icon for a standard Open button in a QDialogButtonBox .

QStyle::SP_DialogSaveButton

43

Icon for a standard Save button in a QDialogButtonBox .

QStyle::SP_DialogCloseButton

44

Icon for a standard Close button in a QDialogButtonBox .

QStyle::SP_DialogApplyButton

45

Icon for a standard Apply button in a QDialogButtonBox .

QStyle::SP_DialogResetButton

46

Icon for a standard Reset button in a QDialogButtonBox .

QStyle::SP_DialogDiscardButton

47

Icon for a standard Discard button in a QDialogButtonBox .

QStyle::SP_DialogYesButton

48

Icon for a standard Yes button in a QDialogButtonBox .

QStyle::SP_DialogNoButton

49

Icon for a standard No button in a QDialogButtonBox .

QStyle::SP_ArrowUp

50

Icon arrow pointing up.

QStyle::SP_ArrowDown

51

Icon arrow pointing down.

QStyle::SP_ArrowLeft

52

Icon arrow pointing left.

QStyle::SP_ArrowRight

53

Icon arrow pointing right.

QStyle::SP_ArrowBack

54

Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight , otherwise SP_ArrowRight.

QStyle::SP_ArrowForward

55

Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight , otherwise SP_ArrowLeft.

QStyle::SP_CommandLink

57

Icon used to indicate a Vista style command link glyph.

QStyle::SP_VistaShield

58

Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.

QStyle::SP_BrowserReload

59

Icon indicating that the current page should be reloaded.

QStyle::SP_BrowserStop

60

Icon indicating that the page loading should stop.

QStyle::SP_MediaPlay

61

Icon indicating that media should begin playback.

QStyle::SP_MediaStop

62

Icon indicating that media should stop playback.

QStyle::SP_MediaPause

63

Icon indicating that media should pause playback.

QStyle::SP_MediaSkipForward

64

Icon indicating that media should skip forward.

QStyle::SP_MediaSkipBackward

65

Icon indicating that media should skip backward.

QStyle::SP_MediaSeekForward

66

Icon indicating that media should seek forward.

QStyle::SP_MediaSeekBackward

67

Icon indicating that media should seek backward.

QStyle::SP_MediaVolume

68

Icon indicating a volume control.

QStyle::SP_MediaVolumeMuted

69

Icon indicating a muted volume control.

QStyle::SP_LineEditClearButton

70

Icon for a standard clear button in a QLineEdit . This enum value was added in Qt 5.2.

QStyle::SP_CustomBase

0xf0000000

Base value for custom standard pixmaps; custom values must be greater than this value.



Так же в этом разделе:
 
MyTetra Share v.0.59
Яндекс индекс цитирования