0% found this document useful (0 votes)
102 views4 pages

INF1511 - Chapter 8 - Using Basic Widgets

Radio buttons allow selection of one option from multiple choices and emit signals when the state changes. Checkboxes allow selection of multiple options and also emit signals when the state changes. Scrollbars contain slider, arrows, and page controls to navigate documents and images, and emit signals when interacted with. Sliders represent integer values and also emit signals when interacted with. List widgets display and manipulate items through methods like insert, remove, select and provide signals about current items.

Uploaded by

Rofhiwa Ramahala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
102 views4 pages

INF1511 - Chapter 8 - Using Basic Widgets

Radio buttons allow selection of one option from multiple choices and emit signals when the state changes. Checkboxes allow selection of multiple options and also emit signals when the state changes. Scrollbars contain slider, arrows, and page controls to navigate documents and images, and emit signals when interacted with. Sliders represent integer values and also emit signals when interacted with. List widgets display and manipulate items through methods like insert, remove, select and provide signals about current items.

Uploaded by

Rofhiwa Ramahala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

INF 1511 – Revision notes – Chapter 8

1. Using Radio Buttons

Radio buttons are used to allow a user to select only one option from two or more options.

Radio buttons provide the following methods;


isChecked() - returns true if the button is in selected state.

setIcon() - used to display an icon with the radio button.

setText() - used to set the text of the radio button. To specify a shortcut key for the
radio button, precede the preferred character in the text with an ampersand (&).

setChecked() - pass the Boolean value true to this method to make the radio button
the default.
Radio buttons emit the following signals;
toggled() - emitted whenever button changes its state from checked to unchecked or
vice versa.

clicked() - emitted when a button is activated (i.e., pressed and released) or when
its shortcut key is pressed.

stateChanged() - emitted when a radio button changes its state from checked to
unchecked or vice versa.

2. Using Checkboxes
Check boxes allow the selection of more than one option.

Checkboxes provide the following methods;

isChecked() - returns true if the checkbox is checked; otherwise returns false.

setTristate() - pass Boolean value true to this method to use the “no change” state
of the checkbox. With this state, you give the user the option of neither checking nor
unchecking a checkbox.
setIcon() - used to display an icon with the checkbox.

setText() - used to set the text of the checkbox. To specify a shortcut key for the
checkbox, precede the preferred character with an ampersand in the text.

setChecked() - pass Boolean value true to this method to make the checkbox
checked by default.

Checkboxes emit the following signals;


toggled() - the signal is emitted whenever a checkbox changes its state from checked
to unchecked or vice versa.

clicked() - the signal is emitted when a checkbox is activated (i.e. pressed and
released) or when its shortcut key is typed.
stateChanged() - the signal is emitted whenever a checkbox changes its state from
checked to unchecked or vice versa.

3. ScrollBars
Scrollbars are used for viewing documents or images that are larger than the view area.
There are two types of scrollbars, HorizontalScrollBar and VerticalScrollBar.

A ScrollBar has the following controls:

Slider handle: Used to move to any part of the document or image quickly.

Scroll arrows: arrows on either side of the scrollbars that are used to accurately navigate to a
particular place in a document or image.

Page control: The page control is the background of the scrollbar over which the slider
handle is dragged.

Scrollbars provide the following methods;

value() - retrieves a value that indicates the distance of the slider handle from the
start of the scrollbar.

setValue() - sets the value of the scrollbar and hence the location of the slider handle
in the scrollbar.

minimum() - returns the minimum value of the scrollbar.

maximum() - returns the maximum value of the scrollbar.

setMinimum() - sets the minimum value of the scrollbar.

setMaximum() - sets the maximum value of the scrollbar.

setSingleStep() - sets the single step value.

setPageStep() - sets the page step value.

Scrollbars emit the following signals

valueChanged() - emitted when the scrollbar’s value is changed.

sliderPressed() - emitted when the user starts to drag the slider handle.

sliderMoved() - emitted when the user drags the slider handle.

sliderReleased() - emitted when the user releases the slider handle.

actionTriggered()Emitted when the scrollbar is changed by user interaction.

4. Sliders
Sliders are used to represent some integer value.
There are two types of Sliders, HorizontalSlider and VerticalSlider.

Sliders emit the following signals

valueChanged() - emitted when the scrollbar’s value is changed.

sliderPressed() - emitted when the user starts to drag the slider handle.

sliderMoved() - emitted when the user drags the slider handle.

sliderReleased() - emitted when the user releases the slider handle.

The following methods are used to set positions of the sliders;

setTickPosition() - sets the position of tickmarks.

setTickInterval() - specifies the number of ticks desired.

tickPosition() - returns the current tick position.

tickInterval() - returns the current tick interval.

5. Working with a List Widget

The List widget is used to list items, the items can then be viewed, added to and removed
from the list.

The list widget provides the following methods;

insertItem() - inserts a new item with the specified text into the List widget at the
specified row.

insertItems() - inserts multiple items from a list of supplied labels, starting at the
specified row.

count() - returns the count of the number of items in the list.

takeItem() - removes and returns item from the specified row in the List widget.

currentItem() - returns the current item in the list.

setCurrentItem() - replaces the current item in the list with the specified item.

addItem() - inserts an item with the specified text at the end of the List widget.

addItems() - inserts items with the specified text at the end of the List widget.

clear() - removes all items and selections in the view permanently.

currentRow() - returns the row number of the current item. If there is no current
item, it returns the value -1.
setCurrentRow() - selects the specified row in the List widget.

item() - returns the item at the specified row.

List widget emits the following signals


currentRowChanged() - emitted whenever the row of the current
item changes.

currentTextChanged() - emitted whenever the text in the current


item is changed.

currentItemChanged() - emitted when the focus of the current


item is changed.

You might also like