DynExp
Highly flexible laboratory automation for dynamically changing experiments.
QtUtil.cpp File Reference

Go to the source code of this file.

Namespaces

 Util
 DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt and its widgets.
 

Functions

const QLocale & Util::GetDefaultQtLocale ()
 Returns the default locale properties to be assigned to Qt widgets. More...
 
void Util::ActivateWindow (QWidget &Widget)
 Renders a window active and brings it to the front. More...
 
DOM functions

These functions can be used to walk through an (XML-)DOM tree.

std::vector< QDomNode > Util::GetChildDOMNodes (const QDomElement &Parent, const QString &ChildTagName)
 Finds child nodes with a certain tag name. More...
 
QDomNode Util::GetSingleChildDOMNode (const QDomElement &Parent, const QString &ChildTagName)
 Finds a single child node with a certain tag name. More...
 
QDomElement Util::GetSingleChildDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element. More...
 
std::string Util::GetStringFromDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMElement() but returns the text from a DOM element. More...
 
template<>
std::string Util::GetTFromDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a certain type using Util::StrToT(). More...
 
QDomAttr Util::GetDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Extracts an attribute from a DOM element. More...
 
std::string Util::GetStringFromDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Behaves like GetDOMAttribute() but returns the text from the attribute. More...
 
template<>
std::string Util::GetTFromDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type using Util::StrToT(). More...
 
File open and save dialogs
QString Util::PromptOpenFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="")
 Opens a file dialog to ask the user to select a single existing file. More...
 
QString Util::PromptSaveFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="")
 Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. More...
 
QString Util::PromptSaveFilePathModule (DynExp::QModuleWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter)
 Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. Furthermore, the dialog automatically derives the initial directory using QModuleWidget::GetDataSaveDirectory() and sets the new global directory for saving data to the folder containing the selected file when the user accepts the dialog. More...
 
Image manipulation
QImage Util::QImageFromBlobData (BlobDataType &&BlobData, int Width, int Height, int BytesPerLine, QImage::Format Format)
 Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership of BlobData's content. More...
 
ImageHistogramType Util::ComputeIntensityHistogram (const QImage &Image)
 Computes an intensity (grayscale) histogram from a QImage object. More...
 
ImageRGBHistogramType Util::ComputeRGBHistogram (const QImage &Image)
 Computes a RGB histogram from a QImage object. More...
 
ImageHistogramType Util::ConvertRGBToIntensityHistogram (const ImageRGBHistogramType &RGBHistogram)
 Computes an intensity (grayscale) histogram from a RGB histogram. More...
 
QPolygonF Util::MakeCrossPolygon (QPointF Center, unsigned int ArmLength)
 Returns a QPolygonF representing a cross-style marker. More...
 
Reading and writing files
bool Util::SaveToFile (const QString &Filename, std::string_view Text)
 Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's content. More...
 
std::string Util::ReadFromFile (const QString &Filename)
 Reads the entire content from a text file. More...
 
std::string Util::ReadFromFile (const std::string &Filename)
 Reads the entire content from a text file. More...
 
std::string Util::ReadFromFile (const std::filesystem::path &Filename)
 Reads the entire content from a text file. More...