![]() |
ImFusion SDK 4.3
|
Some Qt convenience functions. More...
Some Qt convenience functions.
Classes | |
| class | ScheduledMainThreadCommand |
Functions | |
| void | disableUnfocusedScrolling (QWidget *widget) |
| Helper method to disable scrolling on a widget when the widget is not in focus. | |
| QStringList | askForFiles (const QString &name, const QString &caption, const QString &filter=QString(), QString *selectedFilter=0, QWidget *parent=0, QWidget *additionalWidget=nullptr, std::optional< bool > dontUseNativeDialog=std::nullopt) |
| Helper method to display a QFileDialog and ask the user for multiple file to open. | |
| QString | getSaveFilename (QWidget *parent, const QString &name, const QString &caption=QString(), const QString &filter=QString(), QString *selectedFilter=0, const QString &defaultDir=QString(), QWidget *additionalWidget=nullptr, const QString &fileName=QString(), std::optional< bool > dontUseNativeDialog=std::nullopt) |
| Helper method to display a QFileDialog and ask the user for a file name to save data. | |
| QString | getOpenFilename (QWidget *parent, const QString &name, const QString &caption=QString(), const QString &filter=QString(), QString *selectedFilter=0, const QString &defaultDir=QString(), QWidget *additionalWidget=nullptr, std::optional< bool > dontUseNativeDialog=std::nullopt) |
| Helper method to display a QFileDialog and ask the user for a single file to open. | |
| QString | getExistingDirectory (QWidget *parent, const QString &name, const QString &caption=QString(), const QString &defaultDir=QString(), QWidget *additionalWidget=nullptr, std::optional< bool > dontUseNativeDialog=std::nullopt) |
| QString | modality (Data::Modality m) |
| Return the name of an image modality. | |
| QString | describe (const SharedImageSet *is) |
| Return a description string for an image data set. | |
| QString | describe (const TrackingSequence *ts) |
| Return a description string for a tracking sequence. | |
| QStringList | describePair (const SharedImageSet *is1, const SharedImageSet *is2) |
| Return brief names for a pair of images, by using their modalities in case they are set and different, and the data names otherwise. | |
| SharedImage * | createImage (const QImage &image) |
| Create a SharedImage from a QT QImage. | |
| int | filesInFolder (const QString &folder, const QString &filename) |
| Check how many files with the given filename wildcard reside in a folder. | |
| void | setCurrentText (QComboBox *element, const QString &value) |
| Qt 4 compatible method to set the current text of a QComboBox. | |
| void | walkItemModel (QAbstractItemModel *model, std::function< void(QModelIndex)> func) |
| Calls func for ever index in model. | |
| void | makeExpandable (QGroupBox *box) |
| Makes the QGroupBox expandable. | |
| QWidget * | makeTabWidget (QTabBar *tabBar, const QList< QPair< QString, QWidget * > > &tabs) |
| Creates a tab widget of the 'tabBar' and a list of 'tabs'. | |
| QProgressDialog * | createProgressDialog (const QString &labelText, const QString &titleText, QWidget *parent=0) |
| template<typename Class> | |
| void | runInBackground (Class *object, void(Class::*fn)(), const QString &labelText, const QString &titleText, QWidget *parent=0) |
| void | runInBackground (std::function< void()> fn, const QString &labelText, const QString &titleText, QWidget *parent=0) |
| void | runInBackgroundWithCancel (std::function< void()> fn, std::function< void()> cancelFn, const QString &labelText, const QString &titleText, QWidget *parent=0) |
| template<typename T> | |
| T | runInBackgroundAndReturn (std::function< T()> fn, const QString &labelText, const QString &titleText, QWidget *parent=0) |
| std::string | toRelativePath (const std::string &absolutePath, const std::string &basePath="", int keepAbsoluteIfDepthExceeds=-1) |
| std::string | toAbsolutePath (const std::string &relativePath, const std::string &basePath="") |
| QString | focusedElideMiddle (const QFont &font, int maxWidth, const QString &left, const QString &middle, const QString &right) |
| void | setDontUseNativeDialogs (bool value) |
| std::unique_ptr< ScheduledMainThreadCommand > | runOnMainThread (std::function< void()> &&function, int waitMs=0) |
Executes the given function asynchronously on the main Qt thread. Waits at least waitMs milliseconds before running it. | |
| void | tableHeightToContent (QTableView *tableView, int minHeight=100, int maxHeight=400) |
| Sets the height of a QTableView to the height of its content. | |
| bool | askForUsernamePassword (QWidget *parent, QString &username, QString &password) |
| Shows a simple username/password dialog. Returns true when OK was clicked. | |
| std::unique_ptr< QMouseEvent > | touchEventToMouseEvent (QEvent *event) |
| Converts a touch event to a mouse equivalent. | |
| bool | warnIfPoseLinked (Data *data1, Data *data2, MainWindowBase *mainWindow) |
| Checks if the data is pose-linked and if yes opens a warning dialog. Returns true if the dialog was accepted. | |
| std::string | base64Encode (const QByteArray &byteArray) |
| Encode a QByteArray using base64 encoding. | |
| QByteArray | base64Decode (const std::string &base64) |
| Decode a base64 encoded string to a QByteArray. | |
| QIcon | generateMultiSizeIcon (const char *name, const char *nameOff=nullptr, const char *nameDisabled=nullptr) |
| Generate a QIcon object with multiple version of an icon (different sizes). | |
| void | updateUiScalingFromSettings () |
| Checks the current settings if a custom scale is to be applied. | |
| double | customUiScaling () |
| Returns the custom Ui scale factor (1.0 means no scaling) | |
| double | dpiScale () |
| Returns the DPI scaling factor of the application (1.0 means no scaling) | |
| double | devicePixelRatio () |
| Returns the devicePixelRatio (1.0 for most displays but 2.0 for Apple retina displays) | |
| void | setPrimaryScreen (const QScreen *primaryScreen) |
| Sets the optional reference screen to use to determine DPI scaling/device pixel ratio. | |
| QColor | convertToQColor (const vec4 &color) |
| Converts a vec4 to a QColor. | |
| QMap< QString, QString > | convertStyleSheet (QString &style) |
| Converts a CSS stylesheet from our extended CSS syntax to regular CSS that Qt understands. | |
| QDate | convertDICOMDate (const std::string &str) |
| Converts the string to a date. | |
| QTime | convertDICOMTime (const std::string &str, std::optional< Dicom::Error > *errorOut=nullptr) |
| Converts the string to a time. | |
| QDateTime | convertDICOMDateTime (const std::string &str, std::optional< Dicom::Error > *errorOut=nullptr) |
| Converts the string to a date time. | |
| QString | convertDICOMSex (const QString &str) |
| Converts the DICOM sex string M, F or O to male, female or other. | |
| QString | formatStr (const QString &str) |
| QImage | generateThumbnail (DcmDataset &dataset, bool copyDataset=false, std::optional< std::uint32_t > frame=std::nullopt) |
| Generates a thumbnail of the given DICOM or a null image if no thumbnail can be generated. | |
Set values of GUI elements without having them emit signals | |
| void | setSilent (QCheckBox *element, bool value) |
| void | setSilent (QGroupBox *element, bool value) |
| Silently set the value of a group box. | |
| void | setSilent (QAction *element, bool value) |
| Silently set the checked status of an Action. | |
| void | setSilent (QAbstractSlider *element, int value) |
| Silently set the value of a slider. | |
| void | setSilent (QSpinBox *element, int value) |
| Silently set the value of a spin box. | |
| void | setSilent (QDoubleSpinBox *element, double value) |
| Silently set the value of a double spin box. | |
| void | setSilent (QComboBox *element, int value) |
| Silently set the current index of a combo box. | |
| void | setSilent (QAbstractButton *element, bool value) |
| Silently set the 'checked' value of a checkable push button. | |
| void | setSilent (QLineEdit *element, const QString &value) |
| Silently set the text of a line edit. | |
| void | setSilent (IntAdjusterWidget *element, int value) |
| Silently set the value of an AdjusterWidget. | |
| void | setSilent (DoubleAdjusterWidget *element, double value) |
| Silently set the value of an AdjusterWidget. | |
| void | setSilent (Vec3Widget *element, const vec3 &value) |
| Silently set the value of an Vec3Widget. | |
| void disableUnfocusedScrolling | ( | QWidget * | widget | ) |
Helper method to disable scrolling on a widget when the widget is not in focus.
I.E. if the user scrolls over a QComboBox, QSpinBox or similar, they will not accidentally change the value
| widget | The widget on which to disable unfocused scrolling. |
| QStringList askForFiles | ( | const QString & | name, |
| const QString & | caption, | ||
| const QString & | filter = QString(), | ||
| QString * | selectedFilter = 0, | ||
| QWidget * | parent = 0, | ||
| QWidget * | additionalWidget = nullptr, | ||
| std::optional< bool > | dontUseNativeDialog = std::nullopt ) |
Helper method to display a QFileDialog and ask the user for multiple file to open.
The selected folder will be remembered.
| parent | Parent widget. |
| name | Identifier for the file type to open. This name will be used to remember the selected folder. |
| caption | Caption of the dialog. |
| filter | Filter to use for the file dialog. |
| selectedFilter | Optionally selected filter. |
| defaultDir | Default directory to use if there is no remembered directory. |
| additionalWidget | Optional QWidget to display next to the file dialog and enable the user to do additional configuration. |
| dontUseNativeDialog | If set this parameter overrides the global setDontUseNative flag |
| QString getSaveFilename | ( | QWidget * | parent, |
| const QString & | name, | ||
| const QString & | caption = QString(), | ||
| const QString & | filter = QString(), | ||
| QString * | selectedFilter = 0, | ||
| const QString & | defaultDir = QString(), | ||
| QWidget * | additionalWidget = nullptr, | ||
| const QString & | fileName = QString(), | ||
| std::optional< bool > | dontUseNativeDialog = std::nullopt ) |
Helper method to display a QFileDialog and ask the user for a file name to save data.
The selected folder will be remembered.
| parent | Parent widget. |
| name | Identifier for the file type to open. This name will be used to remember the selected folder. |
| caption | Caption of the dialog. |
| filter | Filter to use for the file dialog. |
| selectedFilter | Optionally selected filter. |
| defaultDir | Default directory to use if there is no remembered directory. |
| additionalWidget | Optional QWidget to display next to the file dialog and enable the user to do additional configuration. |
| defaultName | Default file name to show in file dialog |
| dontUseNativeDialog | If set this parameter overrides the global setDontUseNative flag |
| QString getOpenFilename | ( | QWidget * | parent, |
| const QString & | name, | ||
| const QString & | caption = QString(), | ||
| const QString & | filter = QString(), | ||
| QString * | selectedFilter = 0, | ||
| const QString & | defaultDir = QString(), | ||
| QWidget * | additionalWidget = nullptr, | ||
| std::optional< bool > | dontUseNativeDialog = std::nullopt ) |
Helper method to display a QFileDialog and ask the user for a single file to open.
The selected folder will be remembered.
| parent | Parent widget. |
| name | Identifier for the file type to open. This name will be used to remember the selected folder. |
| caption | Caption of the dialog. |
| filter | Filter to use for the file dialog. |
| selectedFilter | Optionally selected filter. |
| defaultDir | Default directory to use if there is no remembered directory. |
| additionalWidget | Optional QWidget to display next to the file dialog and enable the user to do additional configuration. |
| dontUseNativeDialog | If set this parameter overrides the global setDontUseNative flag |
| void setSilent | ( | QCheckBox * | element, |
| bool | value ) |
Silently set the value of a check box
| void makeExpandable | ( | QGroupBox * | box | ) |
Makes the QGroupBox expandable.
An expandable QGroupBox becomes checkable and receives a special style. When it is unchecked, the widgets inside the QGroupBox are not visible. This can be used to, for example, group and hide advanced settings.
| QWidget * makeTabWidget | ( | QTabBar * | tabBar, |
| const QList< QPair< QString, QWidget * > > & | tabs ) |
Creates a tab widget of the 'tabBar' and a list of 'tabs'.
Each item in 'tabs' contains the title of the tab and the widget representing the tab content. The returned widget contains the tabBar and all tab widgets, and must be deleted by the caller (or added to a layout). The 'tabBar' and 'tabs' are removed from their current layout (if they have any) and are re-parented to the returned widget. Contrary to a QTabWidget, the vertical size of the tab widget depends on the current tab and not on the tab with the largest vertical size.
NOTE: This is currently only styled correctly with a documentMode QTabBar.
| QIcon generateMultiSizeIcon | ( | const char * | name, |
| const char * | nameOff = nullptr, | ||
| const char * | nameDisabled = nullptr ) |
Generate a QIcon object with multiple version of an icon (different sizes).
The name will be automatically resolved to multiple resource paths. For example IconClose.png becomes :/icons/16/IconClose.png, :/icons/32/IconClose.png... The returned icons will be cached internally.
| void setPrimaryScreen | ( | const QScreen * | primaryScreen | ) |
Sets the optional reference screen to use to determine DPI scaling/device pixel ratio.
If this is null, will use what the Qt backend considers the primary screen.
| QMap< QString, QString > convertStyleSheet | ( | QString & | style | ) |
Converts a CSS stylesheet from our extended CSS syntax to regular CSS that Qt understands.
The extended CSS syntax supports variables using @ (similar to Less):
Additionally it will scale all px values with customUiScaling() * dpiScale() for better support in high dpi displays.
| QDate convertDICOMDate | ( | const std::string & | str | ) |
Converts the string to a date.
Aside from the standard DICOM format yyyyMMdd, it will also try the following formats (in that order): yyMMdd, ddMMyyyy, ddMMyy The first format producing a valid QDate is used. If no format is working an invalid QDate is returned. http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html
| QTime convertDICOMTime | ( | const std::string & | str, |
| std::optional< Dicom::Error > * | errorOut = nullptr ) |
Converts the string to a time.
If a non-standardised time is parsed, an InvalidElementValue warning will be added to errorOut. If a time cannot be parsed at all, an InvalidElementValue error will be added to errorOut and an invalid QTime is returned. http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html
| QDateTime convertDICOMDateTime | ( | const std::string & | str, |
| std::optional< Dicom::Error > * | errorOut = nullptr ) |
Converts the string to a date time.
We currently don't support all allowed combinations. Especially omitting parts but still specify a timezone is not well supported. The timezone is always converted to UTC. http://dicom.nema.org/dicom/2013/output/chtml/part05/sect_6.2.html
| QString convertDICOMSex | ( | const QString & | str | ) |
Converts the DICOM sex string M, F or O to male, female or other.
Any other string is returned unchanged.
| QImage generateThumbnail | ( | DcmDataset & | dataset, |
| bool | copyDataset = false, | ||
| std::optional< std::uint32_t > | frame = std::nullopt ) |
Generates a thumbnail of the given DICOM or a null image if no thumbnail can be generated.
Optionally clones the given dataset. This is recommended when this function is called from another thread since DcmDataset isn't entirely thread-safe. For multi-frame dicom a specific frame can be optionally selected