Logo    
KDWinUtils
Helper library for MFC to Qt migration
Loading...
Searching...
No Matches
KText Class Reference

Class used as member for DDX_Text data exchange. More...

#include <ktext.h>

Public Member Functions

int Compare (const QString &other) const
 Compares two strings (case-sensitive).
 
const char * constData () const
 Converts to a const char * implicitly.
 
template<typename T , typename... Ts>
KTextFormat (T &&format, Ts... args)
 Writes formatted data to the widget in the same way that sprintf_s formats data into a C-style character array.
 
 KText ()
 
 KText (const char *text)
 
 KText (const CString &text)
 
 KText (const KText &other)=delete
 
 KText (const wchar_t *text)
 
 KText (QString text)
 
 operator CString () const
 
 operator QString () const
 
 operator std::string () const
 
 operator std::wstring () const
 
KTextoperator= (const char *text)
 
KTextoperator= (const CString &text)
 
KTextoperator= (const KText &other)=delete
 
KTextoperator= (const QString &text)
 
KTextoperator= (const wchar_t *text)
 
void setValidator (QValidator *validator)
 Sets a validator to the widget associated with this KText.
 
void setWidget (QWidget *label)
 Sets the widget associated with this KText.
 
CString toCString () const
 
QString toQString () const
 
std::string toStdString () const
 
std::wstring toStdWString () const
 
QWidget * widget () const
 Returns the widget associated with this KText.
 
 ~KText ()
 

Detailed Description

Class used as member for DDX_Text data exchange.

This class serves as a proxy on top of an existing Qt widget, with an API similar to the API of a CString in MFC, when used as the data member in DDX_Text data exchange routine. It currently supports QLabel, QLineEdit and QComboBox widgets.

See also
https://learn.microsoft.com/en-us/cpp/mfc/reference/standard-dialog-data-exchange-routines#ddx_text

Constructor & Destructor Documentation

◆ KText() [1/6]

KText::KText ( )

◆ KText() [2/6]

KText::KText ( const wchar_t * text)
explicit

◆ KText() [3/6]

KText::KText ( const char * text)
explicit

◆ KText() [4/6]

KText::KText ( QString text)
explicit

◆ KText() [5/6]

KText::KText ( const KText & other)
delete

◆ ~KText()

KText::~KText ( )

The destructor will remove the QByteArray generated by a constData call.

◆ KText() [6/6]

KText::KText ( const CString & text)
explicit

Member Function Documentation

◆ Compare()

int KText::Compare ( const QString & other) const

Compares two strings (case-sensitive).

◆ constData()

const char * KText::constData ( ) const

Converts to a const char * implicitly.

This method is used mainly for compatibility for old API or code. This method creates and store a QByteArray internally, to be avoided if possible

Deprecated
Use explicit conversion methods

◆ Format()

template<typename T , typename... Ts>
KText & KText::Format ( T && format,
Ts... args )
inline

Writes formatted data to the widget in the same way that sprintf_s formats data into a C-style character array.

◆ operator CString()

KText::operator CString ( ) const

◆ operator QString()

KText::operator QString ( ) const

◆ operator std::string()

KText::operator std::string ( ) const

◆ operator std::wstring()

KText::operator std::wstring ( ) const

◆ operator=() [1/5]

KText & KText::operator= ( const char * text)

◆ operator=() [2/5]

KText & KText::operator= ( const CString & text)

◆ operator=() [3/5]

KText & KText::operator= ( const KText & other)
delete

◆ operator=() [4/5]

KText & KText::operator= ( const QString & text)

◆ operator=() [5/5]

KText & KText::operator= ( const wchar_t * text)

◆ setValidator()

void KText::setValidator ( QValidator * validator)

Sets a validator to the widget associated with this KText.

◆ setWidget()

void KText::setWidget ( QWidget * label)

Sets the widget associated with this KText.

This method is usually called in the DoDataExchange method during the migration. Only the constructor is allowed before calling this method.

Parameters
labelWidget used, only QLabel, QLineEdit and QComboBox are supported

◆ toCString()

CString KText::toCString ( ) const

◆ toQString()

QString KText::toQString ( ) const

◆ toStdString()

std::string KText::toStdString ( ) const

◆ toStdWString()

std::wstring KText::toStdWString ( ) const

◆ widget()

QWidget * KText::widget ( ) const

Returns the widget associated with this KText.


The documentation for this class was generated from the following file: