QUESTIONS AND
ANSWERS
FOR ASSISTANCE CONTACT
EMAIL:gabrielmusyoka940@gmail.com
, lOMoARcPSD|31863004
Question 1 (Advanced Widgets)
1 What are widgets and why are they useful in programming? (2)
Widgets are items which facilitate the building of Graphical User Interfaces which specify
a specific type of user-interaction. They are precoded which saves programmers a lot of
time. They provide a quick and easy way for designing user interfaces.
2 Name any 3 widgets that you have used in programming (3)
ComboBox, LineEdit, Calendar Widget, LCD Widget
3 Explain how you would add a LCD widget and how you can use this to show the
system time (5)
• Drag and Drop the LCD Number Widget onto a dialog
• Then convert the ui to a python file
• You create an instance of QTimer and assign it to a name e.g. timer.
timer=QtCore.QTimer(self).
• You connect the timout method to a function that fetches the system clock.
timer.timout.connect(self.showlcd)
• you then add the timing to the timout function: timer.timeout(1000) every 1000ms
• Then for every 1000ms, you show the self.showlcd()
• The showlicd method connects to an instance of the systems clock. time =
QtCore.Qtime.currentTime()
• You then convert the time to text and display it via the LCDNumber.
text=time.toString('hh:mm”) self.ui.LCDNumber.display(text)
4 Explain how you would add a calendar widget and how you can use this to display the
date selected in a date edit widget.
• Drag and Drop the QCalendarWidget onto a dialog and a dateEditWidget
• Then convert the ui to a python file
• You then connect the calendars on selectionChanged() Signal to a slot method that will
display the date from the calendar on the dateEditWidget.
• QtCore.QObject.connect(self.ui.calendarWidget, QtCore.SIGNAL(‘selectionChanged()’),
self.dispdate.
• def dispdate(self):
self.ui.dateEdit.setDate(self.ui.calendarWidget.selectedDate())
, lOMoARcPSD|31863004
5 Why is a comboBox useful in applications? (1)
It displays the items that are listed using minimal screen space.
6 Explain how can you use a combo box in a GUI (3)
You drag a combo box into the dialog
You convert the file to a py file.
You then add items to the combo box by using the ComboBox.addItem() method
You can add the items of a combo box using a loop
To change screens of a stackedView
To select items of text
Pixmaps
Question 2 (Menus and Toolbars)
Use the diagram below to answer the questions that follow.
7 Explain how would you create a Menu bar with File and under File three placeholders
with Edit, copy and paste (2)
Where it says type here you type here Type File and Press Enter. Then Type Edit and
press Enter, Type Copy – press Enter, type Paste, Press Enter
8 Explain how you would you create a shortcut key for the copy and paste submenus (4)
You activate the action editor. Select on the action item for copy and double click. A window
pops up and you type the shortcut key in the place allocated for shortcut. You do the same for
paste.
9 How is a menu bar different from a toolbar (2)
A menubar can have many drop down menus with many items for each list. You can only have
one toolbar and it uses icons.
10 What is a placeholder? (1)
A placeholder is a place that has been reserved so that the user can add text or a picture to it.
Downloaded by Gabriel Musyoka (gabrielmusyoka940@gmail.com)
, lOMoARcPSD|31863004
11 How would you add a separator in a menu to create a nested menu? (2)
Double click the add Seperator option in the drop down menu
12 Explain how an Action Editor works (4)
An action editor initiates actions generated by the user. The action editor works with user
initiated actions via menu bars, toolbars and shortcut keys. On occurrence of an action and
function is executed in response to the action initiated.
Creating a toolbar
13 What is a toolbar useful for (1)
A toolbar displays icons instead of text to represent the task that it can perform
14 Explain briefly how you would create an action with an icon
You would go the action editor, select new, Give the action a name, assign an icon to it either
through the file system or a resource file. Then drag the action to a toolbar.
DOCK WIDGET
Questions
15 What is a docked widget and why is it useful?
16 Name 4 areas that you can place a dock widget
LeftDockWidgetArea
RightDockWidgetArea
TopDockWidgetArea
BottomDockWidgetArea
17 What property should you enable to make the dock area movable
DockWidgetMovable
TAB WIDGET
Questions
18 What is the purpose of a tab widget
It is used to created detachable tool pallets and widget panels
19 How do you convert a tab to a widget
Right click on it and select Morph into
20 How do you change the style, gradient and colour of a tabbed document?
Through the style sheet
21 Give 4 reasons why it is important to use Menus in an application (3) ????
• users rely on menus to find content and use features.
• Menus can have multiple items listed under each menu which in tern can also have
submenus, as well as seperators. Each item in a menu performs an action related to the
action Editor.
Downloaded by Gabriel Musyoka (gabrielmusyoka940@gmail.com)
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller gabrielmusyoka940. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $2.50. You're not tied to anything after your purchase.