QControl

From LabVIEW Wiki
(Redirected from QControls)
Jump to: navigation, search
QControl Class Green.png

A QControl is an object-oriented alternative to using an XControl created by Quentin "Q" Alldredge from Q Software Innovations, LLC.  It allows a developer to create useful, highly customized User Interface (UI) components in LabVIEW of which the behavior is extensible and reusable.

It is:

  • A LabVIEW Object-Oriented Class with a Control Reference as part of its Private Data where all manipulation of the Control should be done through Properties and Methods of its Class
  • A class that can be reused to recreate the UI Logic wherever required
  • Could have an asynchronously called Event Hander that handles UI Logic
  • Part of the QControl Class Hierarchy which mimics the VI Server Class Hierarchy

Tradeoffs of a QControl vs an XControl

There are tradeoffs to using a QControl versus using a regular XControl.

A QControl has the same benefits of an XControl by:

  • Encapsulating UI Logic Code
  • Maintaining the same functionality when used in multiple instances
  • Allowing for complicated UI code to be abstracted from other developers
  • Allowing for custom properties accessible through Property Nodes

It is better than an XControl by:

However, it does have the drawbacks of:

  • Not having customizable Edit Time behavior
  • Not being able to define Data Type
  • Not being able to enforce the use of the defined façade
  • Slightly more complicated programming in usage (does not exist as just a terminal on the block diagram)
  • Slightly more complicated when programming a custom control with more than one control in it

Why use a QControl instead of an XControl?

If the Tradeoffs above didn’t help here is a more detailed explanation.  XControls have two main problems with their implementation that boil down to when an XControl is running.

First, the nature of an XControl is that it is always running when it’s owning VI is in memory but only reacts during the user’s interaction with it.  An XControl starts and its Init Ability executes when the XControl is placed on the Front Panel of a VI that is not in a Library or Class or when said VI opens and is loaded into memory.  The XControl then closes and its Uninit Ability (if it has one) executes when that VI leaves memory or when the XControl is deleted from the VI.

This becomes more complicated if the owning VI is in a Library or Class.  All VIs in Libraries or Classes are loaded into memory when the Library or Class is loaded into memory.  This means that the Init and Uninit Abilities run at the load and unload of the Library or Class and not during the load and close of the owning VI.  Loading of Libraries and Classes, unless called dynamically, are when the Project loads and closes.  XControls become even more unstable if it is compiled and used from Packed Project Libraries (PPLs) and/or is used when a LabVIEW Class Object is its data type.  As such XControls are also not recommended for use with the Actor Framework.

Second, XControls are difficult to handle during the edit time of the owning VI.  Because they are always running, interaction during edit time has to be programmed into the XControl (an XControl has a flag that tells it if the owning VI is in Run Mode or Edit Mode).  This causes a lot more coding necessary just for the ease of the developer that will never be seen by the end user.  Also any properties and method to the control(s) on the Façade have to be recreated as Property and Method Abilities of the XControl.

QControls on the other hand do not execute until the owning VI executes.  All edit time behavior is conserved.  There is no limitations for use in VIs that are part of other Libraries or Classes including PPLs and the Actor Framework.

Also, while using the QControl Toolkit, all properties of the control it is based on, when consisting of single controls, are passed through by nature of inheritance in the QControl Class Hierarchy.  (QControls that have more than one control in a cluster can still have the properties and methods pass through but they would have to be created just as they would have to be created in an XControl.)

Extended QControls

Extended QControls refers to QControls that have been created and shared to the community. These are available to download from the links on their respective pages.

AnimationRing QControl

The AnimationRing QControl s a QControl that inherits from and extends the Ring control, specifically a Picture Ring.  It cycles the value of the ring which contains a frame of the animation.  The frame rate is settable by property.

BreadcrumbNavigator QControl

The BreadcrumbNavigator QControl is a QControl that inherits from and extends the String control. It acts like a list of HTML-like links to help provide navigation in an application. Add items through an included property. Clear all items through an included method. When an item is clicked on, anything after it is removed from the list and the clicked item is returned.

Calendar QControl

The Calendar QControl is a QControl that inherits from and extends the Cluster control.  It implements multiple buttons, lists, etc. to implement a Calendar.

DataGrid QControl

The DataGrid QControl is a QControl that inherits and extends the Multicolumn Listbox control. It functions as a completely LabVIEW-implemented Data Grid where the column data type is defined at edit time by the developer.  The user is then constrained by that data type when inputting data into the Multicolumn Listbox.

RichTextBox QControl

The RichTextBox QControl is a QControl that inherits and extends the String control. It functions as a completely LabVIEW-implemented Rich Text Box.  Under the hood it uses an HTML-like tagged string to define the formatting; there are two main methods: one that converts the tagged string to the formatted string and one that converts the formatted string to the tagged string.

SpellcheckString QControl

The SpellcheckString is a QControl that inherits from and extends the String control. It implements run-time spell checking inside of a String control. It highlights misspelled words by underlining and changing the color to red. Right-clicking on a misspelled word opens a menu with the suggestions and an option to add word to dictionary.

External Links

Get the QControl Toolkit

Other Resources for Learning about QControls