Source Code (Gui Example 46)
Text is often displayed using a QLabel or QTextEdit widget. If you want more control over how the text is drawn to the screen or the printer, consider using QPainter in a custom widget.
Text is often displayed using a QLabel or QTextEdit widget. If you want more control over how the text is drawn to the screen or the printer, consider using QPainter in a custom widget.
A widget which provides a defined list of values is referred to as a combo box and contains a line edit field and a drop down list. The idea of a combo box is to provide a graphical interface for users to select an item from a restricted set of options. The purpose of this example is to explain how to display a subset of the values based on some criteria.
Debug and warning messages can be sent to a separate window which is independent of the application main window. This is normally used for testing or debugging purposes. The information in this post explains how to enable the console output for a CopperSpice application.
Expanding upon the prior example, let’s look at how to receive and parse user command line arguments. This application will show how to use a GUI window to display the auto generated help text or the program version number, based on the passed arguments from the user.
In this example the command line is retrieved and the arguments passed by the user are displayed. Two extra positional arguments are added by the program to demonstrate the QCommandLineParser class.
This example demonstrates how to find the operating system name and version where the application is currently running. Macros are used to isolate the platform specific source code.
Countries and various areas around the world have different formatting conventions for fields like dates, times, numbers, and currency. The set of rules used in a particular region or associated with a specific language is called a locale. The QLocale class is used to format data based on the combination of a given language or country.
A regular expression is a sequence of characters which defines a search pattern. It is used to search, extract, or replace text in an existing string. This example contains a few different ways to use the QRegularExpression class.
The QStringParser class provides a variety of methods to process strings of text. This example will show how to use split() and formatArg().
Although English is one of the most common languages, a well designed user interface should be shown using the language most appropriate for the user. CopperSpice provides built in support for text translations. This example will show how to switch between English and German text at run time by using an external translation file.
A GUI layout will typically contain multiple widgets which have a fixed position and a fixed size. The QSplitter class adds functionality for the user to modify the size of any child widgets, by dragging the boundary located between the controls.
This example shows how to create a resource file which contains a list of various file names which will be embedded in your application. When the executable is created the files listed in the resource file are bundled into the executable. The original files, which are now embedded, do not need to be distributed with the binary. The most common type of files include images, text, icons, and translation files.
The program for this example displays a plain TextEdit widget which contains source code. Portions of the text are highlighted in various colors using the GUI syntax highlighting class.
This example shows how to use low level drawing methods to create an ellipse, rounded rectangle, or a path shape and then set the pen to draw the border and the brush for the fill characteristics.
This example demonstrates how to use low level drawing methods to create a polygon shape and then set the pen to draw the border and the brush for the fill characteristics.