PyQt MCQs

PyQt is a GUI widget toolkit that was developed by the British firm Riverbank Computing. It is a Python interface for Qt which is a popular cross-platform GUI library. PyQt supports a large set of modules, classes, and functions to work with the graphical user interface as well as files and directories, XML, Images, databases, and many more.

PyQt MCQs: This section contains multiple-choice questions and answers on PyQt. These MCQs are written for beginners as well as advanced, practice these MCQs to enhance and test the knowledge of PyQt.

List of PyQt MCQs

1. What is PyQt?

  1. GUI widgets toolkit
  2. CUI widgets toolkit
  3. Python Mathematics library for scientific purposes
  4. Python Mathematics library for quantity management

Answer: A) GUI widgets toolkit

Explanation:

Python PyQt is a Graphical User Interface (GUI) widgets toolkit i.e., you can say PyQt is an interface for Qt n Python.

Discuss this question


2. Which module contains non-GUI functionalities to work with the files and directories in Python?

  1. QtCui
  2. PyQtCui
  3. QtCore
  4. QtGui

Answer: C) QtCore

Explanation:

There is a module named QtCore in PyQt that provides the classes and functions for working with the files and directories in Python.

Discuss this question


3. The ____ class provides a dialog widget for specifying colors.

  1. QtColorDialog
  2. QColorDialog
  3. QtColors
  4. QColors

Answer: B) QColorDialog

Explanation:

In PyQt, the QColorDialog class provides a dialog widget for specifying colors.

Discuss this question


4. Which module contains GUI functionalities to work with the graphical interface in Python?

  1. QtGraphical
  2. PyQtGui
  3. QtCore
  4. QtGui

Answer: D) QtGui

Explanation:

There is a module named QtGui in PyQt that provides the classes and functions for working with the graphical interface in Python.

Discuss this question


5. Which is the correct import statement to import QtGui Module?

  1. from PyQt4 import PyQtGui
  2. from PyQt4 import QtGui
  3. import PyQt4 from QtGui
  4. Both A and B

Answer: B) from PyQt4 import QtGui

Explanation:

The correct import statement to import QtGui Module in Python is:

from PyQt4 import QtGui

Discuss this question


6. Which function is used for defining the size and position of a window in PyQt?

  1. setgeometry()
  2. setGeometry()
  3. getSetGeometry()
  4. set_Geometry()

Answer: B) setGeometry()

Explanation:

PyQt's method setGeometry() is used to define the size and position of the Window.

Syntax:
window.setGeometry(x, y, width, height)

Discuss this question


7. Which class is used for rendering and editing HTML in PyQt?

  1. QtWebKit
  2. QtGuiWebKit
  3. QtHtml
  4. Both B and C

Answer: A) QtWebKit

Explanation:

PyQt's class QtWebKit is used for rendering and editing HTML. The QtWebKit is one of the major engines to render webpages and execute JavaScript code.

Discuss this question


8. Which class is used for network programming in PyQt?

  1. QtNet
  2. QtNetworking
  3. QtNetwork
  4. QtNetworkProgramming

Answer: C) QtNetwork

Explanation:

The PyQt's class QtNetwork is used for network programming. The QtNetwork class provides the functionalities (classes, methods, and set of APIs) for programming applications that use TCP/IP operations such as requests, cookies, and sending data over HTTP.

Discuss this question


9. Which is/are the popular method(s) of QBoxLayout class in PyQt?

  1. addWidget()
  2. addStretch()
  3. addLayout()
  4. All of the above

Answer: D) All of the above

Explanation:

All of the given methods of the QBoxLayout class. They are used for various purposes such as the addWidget() method is used to add a widget to the BoxLayout, the addStretch() method is used to create an empty stretchable box, and the addLayout() method is used to add another nested layout.

Discuss this question


10. Which object acts as a placeholder to display non-editable text or image, or a movie of animated GIF in PyQt?

  1. QLabel
  2. QText
  3. QEditText
  4. QEditLabel

Answer: A) QLabel

Explanation:

A QLabel object acts as a placeholder to display non-editable text or image, or a movie of animated GIF.

Discuss this question


11. Which object(s)/widget(s) is/are used for drawing menus in QMainWindow?

  1. QMenuBar
  2. QMenu
  3. QAction
  4. All of the above

Answer: D) All of the above

Explanation:

The QMenuBar, QMenu, and QAction widgets are used for drawing menus in QMainWindow.

Discuss this question


12. Which function is used to create a popup menu in PyQt?

  1. addPopupMenu()
  2. createPopupMenu()
  3. createPmenu()
  4. QPopupMenu()

Answer: B) createPopupMenu()

Explanation:

In Python, PyQt API has a function named createPopupMenu() which is used for creating a popup menu.

Discuss this question


13. QMessageBox class is used to ____ in PyQt.

  1. Create message box
  2. Create popup box
  3. Send a message over TCP/IP
  4. All of the above

Answer: A) Create message box

Explanation:

QMessageBox class is used to create a message box in PyQt.

Discuss this question


14. PyQt was developed by which company?

  1. Riverbank Computing
  2. IBM
  3. Microsoft
  4. None of the above

Answer: A) Riverbank Computing

Explanation:

PyQt was developed by the british firm Riverbank computing.

Discuss this question


15. Which is the correct statement to set the position of a widget 'dispWin' to position x and y?

  1. dispWin.move(x, y)
  2. dispWin.windowMove(x, y)
  3. dispWin.setPosition(x, y)
  4. dispWin.position(x, y)

Answer: A) dispWin.move(x, y)

Explanation:

The correct code statement to set the position of a widget 'dispWin' to position x and y is:

dispWin.move(x, y)

Discuss this question


16. The getText() and setText() are the methods of ___ module.

  1. QtEditText
  2. QLineEdit
  3. QtLineEdit
  4. QtText

Answer: B) QLineEdit

Explanation:

The getText() and setText() are the methods of QLineEdit module. Where, the setText() is used for setting the text programmatically, and the getText() is used for getting the text.

Discuss this question


17. Which is the correct code statement to add an option in the menu in PyQt?

  1. menu.addNewMenu('option_name')
  2. menu.Add('option_name')
  3. menu.newMenu('option_name')
  4. menu.addMenu('option_name')

Answer: D) menu.addMenu('option_name')

Explanation:

The correct code statement to add an option in the menu in PyQt is:

menu.addMenu('option_name')

Where menu is the name of the menu bar and option_name is the new option to be added.

Discuss this question


18. Which class is used to align the widgets horizontally in PyQt?

  1. QtBoxLayout
  2. QHBoxLayout
  3. QtHBoxLayout
  4. PyQtHBoxLayout

Answer: B) QHBoxLayout

Explanation:

PyQt provides QHBoxLayout class which is used to arrange widgets in a horizontal box.

Discuss this question


19. Which class is used to align the widgets in two columns in PyQt?

  1. QFormLayout
  2. QLayout
  3. QTwoColumns
  4. None of the above

Answer: A) QFormLayout

Explanation:

PyQt provides QFormLayout class which is used to arrange widgets in two columns.

Discuss this question


20. Which class is used to align the widgets vertically in PyQt?

  1. QtBoxLayout
  2. QVBoxLayout
  3. QtVBoxLayout
  4. PyQtVBoxLayout

Answer: B) QVBoxLayout

Explanation:

PyQt provides QVBoxLayout class which is used to arrange widgets in a vertical box.

Discuss this question


21. Which is/are the layout manager class(s) in PyQt?

  1. QHBoxLayout
  2. QVBoxLayout
  3. QGridLayout
  4. QFormLayout
  5. All of the above

Answer: E) All of the above

Explanation:

There are four general-purpose layout manager classes in PyQt.

  • QHBoxLayout class is used to arrange widgets in a horizontal box.
  • QVBoxLayout class is used to arrange widgets in a vertical box.
  • QGridLayout class is used to arrange widgets in a grid.
  • QFormLayout class is used to arrange widgets in two columns.

Discuss this question


22. Which is the correct code statement to create a canvas in PyQt?

  1. self.image = QImage(self.size(), QImage.Format_RGB32)
  2. self.image = QImage()
  3. self.image = QImage(QImage.Format_RGB32, self.size())
  4. None of the above

Answer: A) self.image = QImage(self.size(), QImage.Format_RGB32)

Explanation:

The correct code statement to create a canvas in PyQt is:

self.image = QImage(self.size(), QImage.Format_RGB32)

Discuss this question


23. How to set or change the style to the spin box text in PyQt?

  1. font.setStyle()
  2. font.setStyle(style)
  3. font.style()
  4. font.style(style)

Answer: B) font.setStyle(style)

Explanation:

The font.setStyle() method can be used to set or change the style to the spin box text in PyQt. Consider the below code statement –

font.setStyle(QFont.StyleOblique) 

Discuss this question


24. ___ method is used to set the database name in PyQt.

  1. setDatabaseName()
  2. setDbName()
  3. setDBName()
  4. QSetDatabaseName()

Answer: A) setDatabaseName()

Explanation:

The setDatabaseName() method is used to set the database name in PyQt.

Discuss this question


25. Which is/are the correct SQL driver(s) to work with PyQt?

  1. QDB2
  2. QIBASE
  3. QMYSQL
  4. QOCI
  5. All of the above

Answer: E) All of the above

Explanation:

All of the above are the correct SQL drivers to work with PyQt. Where QDB2 is used for IBM DB2, QIBASE is used for Borland InterBase Driver, QMYSQL is used for MySQL Driver, and QOCI is used for Oracle Call Interface Driver.

Discuss this question


26. Which driver is used for Microsoft SQL Server in PyQt?

  1. QMSSQL
  2. QMSDB2
  3. QODBC
  4. None of the above

Answer: C) QODBC

Explanation:

The QODBC is the SQL driver in PyQt which is an ODBC driver and is also used for Microsoft SQL Server.

Discuss this question


27. Which driver is used for SQLite version 3 or above in PyQt?

  1. QSQLITE3
  2. QSQLITE3x
  3. QSQLITE2
  4. QSQLITE

Answer: D) QSQLITE

Explanation:

The QSQLITE driver is used for SQLite version 3 or above. Whereas, QSQLITE2 is used for SQLite version 2.

Discuss this question


28. MDI stands for ____ in PyQt.

  1. Multiple Drawing Interface
  2. Multiple DialogBox Interface
  3. Multiple Document Interface
  4. None of the above

Answer: C) Multiple Document Interface

Explanation:

The MDI stands for Multiple Document Interface in PyQt.

Discuss this question


29. Which class provides access to a system-wide clipboard in PyQt?

  1. QtClipboard
  2. QClipboard
  3. PyQtClipboard
  4. QSysClipboard

Answer: B) QClipboard

Explanation:

PyQt has a class QClipboard that provides access to a system-wide clipboard for the various operations related to copy and paste.

Discuss this question


30. Which QClipboard class's method is used to copy QImage into the clipboard in PyQt?

  1. copyImage()
  2. copyQImage()
  3. setQImage()
  4. setImage()

Answer: D) setImage()

Explanation:

The setImage() is a method of QClipboard class that is used to copy a QImage into a clipboard in PyQt

Discuss this question




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.