Z DooBLER wiki
Wstęp
Więcej...
| Tekst oryginalny
|
| The QAbstractButton class is the abstract base class of button widgets, providing functionality common to buttons.
|
#include <QAbstractButton>
Dziedziczy z
QWidget.
Jest dziedziczony przez
Q3Button, QCheckBox, QPushButton, QRadioButton, QToolButton.
Właściwości
- autoExclusive : bool
- autoRepeat : bool
- autoRepeatDelay : int
- autoRepeatInterval : int
- checkable : bool
- checked : bool
|
- down : bool
- icon : QIcon
- iconSize : QSize
- shortcut : QKeySequence
- text : QString
|
- 57 właściwości jest dziedziczonych z QWidget
- 1 właściwość jest dziedziczona z QObject
Publiczne funkcje
- QAbstractButton ( QWidget * parent = 0 )
- ~QAbstractButton ()
- bool autoExclusive () const
- bool autoRepeat () const
- int autoRepeatDelay () const
- int autoRepeatInterval () const
- QButtonGroup * group () const
- QIcon icon () const
- QSize iconSize () const
- bool isCheckable () const
- bool isChecked () const
- bool isDown () const
- void setAutoExclusive ( bool )
- void setAutoRepeat ( bool )
- void setAutoRepeatDelay ( int )
- void setAutoRepeatInterval ( int )
- void setCheckable ( bool )
- void setDown ( bool )
- void setIcon ( const QIcon & icon )
- void setShortcut ( const QKeySequence & key )
- void setText ( const QString & text )
- QKeySequence shortcut () const
- QString text () const
- 206 publicznych funkcji jest dziedziczonych z QWidget
- 29 publicznych funkcji jest dziedziczonych z QObject
- 12 publicznych funkcji jest dziedziczonych z QPaintDevice
Publiczne sloty
- void animateClick ( int msec = 100 )
- void click ()
- void setChecked ( bool )
- void setIconSize ( const QSize & size )
- void toggle ()
- 19 publicznych slotów jest dziedziczonych z QWidget
- 1 publiczny slot jest dziedziczony z QObject
Sygnały
- void clicked ( bool checked = false )
- void pressed ()
- void released ()
- void toggled ( bool checked )
- 1 sygnał jest dziedziczony z QWidget
- 1 sygnał jest dziedziczony z QObject
Chronione funkcje
- virtual void checkStateSet ()
- virtual bool hitButton ( const QPoint & pos ) const
- virtual void nextCheckState ()
- 38 pchronionych funkcji jest dziedziczonych z QWidget
- 7 pchronionych funkcji jest dziedziczonych z QObject
- 1 chroniona funkcja jest dziedziczona z QPaintDevice
Dodatkowo dziedziczone
- 4 static public members inherited from QWidget
- 5 static public members inherited from QObject
- 1 chroniony slot jest dziedziczony z QWidget
Opis szczegółowy
Klasa QAbstractButton jest abstrakcyjną podstawą klas przycisków, zawiera ich podstawową funkcjonalność.
| Tekst oryginalny
|
| The QAbstractButton class is the abstract base class of button widgets, providing functionality common to buttons.
|
Ta klasa opisuje abstrakcyjny przycisk. Jej klasy potomne przechwytują akcje użytkowników i określają wygląd przycisków.
| Tekst oryginalny
|
| This class implements an abstract button. Subclasses of this class handle user actions, and specify how the button is drawn.
|
QAbstractButton wspiera tworzenie obu typów przycisków - przycisk zwykły (wciskany?) i przyciski zaznaczane (checkbox, radio). Przyciski zaznaczane są opisane przez klasy QRadioButton oraz QCheckBox. Przyciski wciskane są opisane przez klasy QPushButton i QToolButton w tym typie przycisku istnieje również możliwość opcji zaznaczenia.
| Tekst oryginalny
|
| QAbstractButton provides support for both push buttons and checkable (toggle) buttons. Checkable buttons are implemented in the QRadioButton and QCheckBox classes. Push buttons are implemented in the QPushButton and QToolButton classes; these also provide toggle behavior if required.
|
Każdy przycisk może wyświetlać etykietę zawierającą tekst i ikonę. Funkcja setText() ustawia tekst, funkcja setIcon() ustawia ikonę. Jeśli przycisk jest nieaktywny jego etykieta się zmienia aby przycisk wyglądał na "nieaktywny".
| Tekst oryginalny
|
| Any button can display a label containing text and an icon. setText() sets the text; setIcon() sets the icon. If a button is disabled, its label is changed to give the button a "disabled" appearance.
|
Jeśli tekst przycisku zawiera znak ampersand ('&') klasa QAbstractButton automatycznie utworzy skrót klawiszowy. Np.
| Tekst oryginalny
|
| If the button is a text button with a string containing an ampersand ('&'), QAbstractButton automatically creates a shortcut key. For example:
|
QPushButton *button = new QPushButton(tr("Ro&ck && Roll"), this);
Skrót Alt+C jest teraz przypisany do przycisku. Kiedy użytkownikużyje tego skrótu przycisk wywoła funkcję animateClick(). Zobacz QShortcut aby dowiedzieć się więcej na temat skrutów. (Aby wyświetlić w tekscie przycisku znak ampersand użyj zapisu '&&')
| Tekst oryginalny
|
| The Alt+C shortcut is assigned to the button, i.e., when the user presses Alt+C the button will call animateClick(). See the QShortcut documentation for details (to display an actual ampersand, use '&&').
|
Możliwe jest ustawienie dowolnego skrótu klawiszowego dzięki funkcji setShortcut(). Jest to przydatne zwłaszcza do przycisków, które nie mają tekstu.
| Tekst oryginalny
|
| You can also set a custom shortcut key using the setShortcut() function. This is useful mostly for buttons that do not have any text, because they have no automatic shortcut.
|
button->setIcon(QIcon(":/images/print.png"));
button->setShortcut(tr("Alt+F7"));
Wszystkie typy przycisków udostępniane w Qt (QPushButton, QToolButton, QCheckBox, QRadioButton) mogą wyświetlać tekst oraz ikonę.
| Tekst oryginalny
|
| All of the buttons provided by Qt (QPushButton, QToolButton, QCheckBox, and QRadioButton) can display both text and icons.
|
Przycisk może zostać ustawiony jako domyślny w oknie dialogowym przez QPushButton::setDefault() i QPushButton::setAutoDefault().
| Tekst oryginalny
|
| A button can be made the default button in a dialog are provided by QPushButton::setDefault() and QPushButton::setAutoDefault().
|
QAbstractButton wprowadza obsługę większości stanów używanych przez przyciski:
- isDown() aktywny gdy przycisk jest wciśnięty.
- isChecked() aktywny kiedy przycisk jest zaznaczony. Tylko przyciski zaznaczalne mogą zostać zaznaczone i odznaczone (zobacz niżej).
- isEnabled() aktywny gdy przycisk może zostać wciśnięty przez użytkownika.
- setAutoRepeat() ustawia czy przycisk ma automatycznie powtarzać akcję kiedy użytkownik go przytrzymuje. autoRepeatDelay i autoRepeatInterval definiują parametry autopowtarzania.
- setCheckable() ustawia czy przycisk ma być zaznaczalny.
| Tekst oryginalny
|
QAbstractButton provides most of the states used for buttons:
- isDown() indicates whether the button is pressed down.
- isChecked() indicates whether the button is checked. Only checkable buttons can be checked and unchecked (see below).
- isEnabled() indicates whether the button can be pressed by the user.
- setAutoRepeat() sets whether the button will auto-repeat if the user holds it down. autoRepeatDelay and autoRepeatInterval define how auto-repetition is done.
- setCheckable() sets whether the button is a toggle button or not.
|
Różnica pomiędzy isDown() i isChecked() jest następująca. Kiedy użytkownik klika przycisk zaznaczalny, jest on najpierw wciskany, a potem pusczany w stanie zaznaczonym. Kiedy użytkownik klika go ponownie (w celu odznaczenia), przycisk jest najpierw w stanie wciśniętym i po puszczenu przechodzi w stan odznaczony (isChecked() i isDown() przyjmują wartość fales)
| Tekst oryginalny
|
| The difference between isDown() and isChecked() is as follows. When the user clicks a toggle button to check it, the button is first pressed then released into the checked state. When the user clicks it again (to uncheck it), the button moves first to the pressed state, then to the unchecked state (isChecked() and isDown() are both false).
|
QAbstractButton może emitować jeden z 4 sygnałów:
- pressed() jest emitowany gdy lewy przycisk myszy jest wciśnięty i kursor znajduje się nad przyciskiem.
- released() jest emitowany gdy lewy przycisk myszy jest puszczany.
- clicked() jest emitowany gdy przycisk jest wciśnięty i puszczony, gdy wciśnięty jest przycisk skrutu, lub gdy wywołane są sloty click() lub animateClick().
- toggled() jest emitowany kiedy stan wciskanego przycisku się zmienia
| Tekst oryginalny
|
QAbstractButton provides four signals:
- pressed() is emitted when the left mouse button is pressed while the mouse cursor is inside the button.
- released() is emitted when the left mouse button is released.
- clicked() is emitted when the button is first pressed and then released, when the shortcut key is typed, or when click() or animateClick() is called.
- toggled() is emitted when the state of a toggle button changes.
|
| Tekst oryginalny
|
| To subclass QAbstractButton, you must reimplement at least paintEvent() to draw the button's outline and its text or pixmap. It is generally advisable to reimplement sizeHint() as well, and sometimes hitButton() (to determine whether a button press is within the button). For buttons with more than two states (like tri-state buttons), you will also have to reimplement checkStateSet() and nextCheckState().
|
Zobacz też QButtonGroup.
Opis Właściwości
autoExclusive
autoExclusive : bool
| Tekst oryginalny
|
| This property holds whether auto-exclusivity is enabled.
|
| Tekst oryginalny
|
| If auto-exclusivity is enabled, checkable buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. In an exclusive button group, only one button can be checked at any time; checking another button automatically unchecks the previously checked one.
|
| Tekst oryginalny
|
| The property has no effect on buttons that belong to a button group.
|
| Tekst oryginalny
|
| autoExclusive is off by default, except for radio buttons.
|
| Tekst oryginalny
|
Access functions:
- bool autoExclusive () const
- void setAutoExclusive ( bool )
|
See also QRadioButton.
autoRepeat
autoRepeat : bool
| Tekst oryginalny
|
| This property holds whether autoRepeat is enabled.
|
| Tekst oryginalny
|
| If autoRepeat is enabled, then the pressed(), released(), and clicked() signals are emitted at regular intervals when the button is down. autoRepeat is off by default. The initial delay and the repetition interval are defined in milliseconds by autoRepeatDelay and autoRepeatInterval.
|
| Tekst oryginalny
|
| Note: If a button is pressed down by a shortcut key, then auto-repeat is enabled and timed by the system and not by this class. The pressed(), released(), and clicked() signals will be emitted like in the normal case.
|
| Tekst oryginalny
|
Access functions:
- bool autoRepeat () const
- void setAutoRepeat ( bool )
|
autoRepeatDelay
autoRepeatDelay : int
| Tekst oryginalny
|
| This property holds the initial delay of auto-repetition.
|
| Tekst oryginalny
|
| If autoRepeat is enabled, then autoRepeatDelay defines the initial delay in milliseconds before auto-repetition kicks in.
|
| Tekst oryginalny
|
| This property was introduced in Qt 4.2.
|
| Tekst oryginalny
|
Access functions:
- int autoRepeatDelay () const
- void setAutoRepeatDelay ( int )
|
See also autoRepeat and autoRepeatInterval.
autoRepeatInterval
autoRepeatInterval : int
| Tekst oryginalny
|
| This property holds the interval of auto-repetition.
|
| Tekst oryginalny
|
| If autoRepeat is enabled, then autoRepeatInterval defines the length of the auto-repetition interval in millisecons.
|
| Tekst oryginalny
|
| This property was introduced in Qt 4.2.
|
| Tekst oryginalny
|
Access functions:
- int autoRepeatInterval () const
- void setAutoRepeatInterval ( int )
|
See also autoRepeat and autoRepeatDelay.
checkable
checkable : bool
| Tekst oryginalny
|
| This property holds whether the button is checkable.
|
| Tekst oryginalny
|
| By default, the button is not checkable.
|
| Tekst oryginalny
|
Access functions:
- bool isCheckable () const
- void setCheckable ( bool )
|
See also checked.
checked
checked : bool
| Tekst oryginalny
|
| This property holds whether the button is checked.
|
| Tekst oryginalny
|
| Only checkable buttons can be checked. By default, the button is unchecked.
|
| Tekst oryginalny
|
Access functions:
- bool isChecked () const
- void setChecked ( bool )
|
See also checkable.
down
down : bool
| Tekst oryginalny
|
| This property holds whether the button is pressed down.
|
| Tekst oryginalny
|
| If this property is true, the button is pressed down. The signals pressed() and clicked() are not emitted if you set this property to true. The default is false.
|
| Tekst oryginalny
|
Access functions:
- bool isDown () const
- void setDown ( bool )
|
icon
icon : QIcon
| Tekst oryginalny
|
| This property holds the icon shown on the button.
|
| Tekst oryginalny
|
| The icon's default size is defined by the GUI style, but can be adjusted by setting the iconSize property.
|
| Tekst oryginalny
|
Access functions:
- QIcon icon () const
- void setIcon ( const QIcon & icon )
|
iconSize
iconSize : QSize
| Tekst oryginalny
|
| This property holds the icon size used for this button.
|
| Tekst oryginalny
|
| The default size is defined by the GUI style. This is a maximum size for the icons. Smaller icons will not be scaled up.
|
| Tekst oryginalny
|
Access functions:
- QSize iconSize () const
- void setIconSize ( const QSize & size )
|
shortcut
shortcut : QKeySequence
| Tekst oryginalny
|
| This property holds the mnemonic associated with the button.
|
| Tekst oryginalny
|
Access functions:
- QKeySequence shortcut () const
- void setShortcut ( const QKeySequence & key )
|
text
text : QString
| Tekst oryginalny
|
| This property holds the text shown on the button.
|
| Tekst oryginalny
|
| If the button has no text, the text() function will return a an empty string.
|
| Tekst oryginalny
|
| If the text contains an ampersand character ('&'), a shortcut is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous shortcut will be overwritten, or cleared if no shortcut is defined by the text. See the QShortcut documentation for details (to display an actual ampersand, use '&&').
|
| Tekst oryginalny
|
| There is no default text.
|
| Tekst oryginalny
|
| Access functions:
QString text () const
void setText ( const QString & text )
|
inne
Tłumaczenie na podstawie oryginalnej dokumentacji ze strony http://doc.trolltech.com
Tekst oryginału http://doc.trolltech.com/4.4/qabstractbutton.html
HTTP: HyperText Transfer ProtocolGUI: Graphical User Interface