|
|
dev:notes_on_porting_to_qt4_examples [2008/08/30 17:43] emrum created |
dev:notes_on_porting_to_qt4_examples [2018/02/07 16:07] |
====== How to convert . qt3->qt4 . kde3->kde4 ====== | |
| |
| |
If somehow possible, **avoid to use the Q3Support** and includes. Use the new Qt4 classes instead. | |
| |
Reason: Q3Support doesn't work as well, as it one might expect and we need to move to Qt4 anyway. | |
| |
| |
===== examples ===== | |
| |
(if you find something new, add it on the top !) | |
| |
(if you find something wrong, tell how it would be better.) | |
| |
------------------------------------------------------- | |
| |
<code> | |
| |
errMsg = i18n(QString("Could not open") ); | |
==> | |
errMsg = i18n(QString("Could not open").toUtf8() ); | |
or | |
errMsg = i18n(QString("Could not open").toUtf8().data() ); | |
| |
| |
Casting std::string to (const char*) | |
==> | |
st.c_str() | |
| |
| |
string.lower() | |
==> | |
string.toLower() | |
| |
| |
outStream.setEncoding('UTF-8') | |
==> | |
outStream.setCodec( (char*)"UTF-8" ); | |
| |
| |
| |
QProgressBar->setProgress(9) | |
==> | |
QProgressBar->setValue(9) | |
| |
| |
| |
if (extraAttributes) // where extraAttributes is QString | |
==> | |
if ( ! extraAttributes.isEmpty() ) | |
| |
| |
| |
| |
KConfig* config = KGlobal::config(); | |
config->setGroup(GeneralOptionsConfigGroup); | |
v = config->readUnsignedNumEntry( .. ) | |
==> | |
// default group: | |
KConfigGroup gconfig = KGlobal::config()->group(""); | |
// or custom: | |
KConfigGroup config = KGlobal::config()->group( GeneralOptionsConfigGrou p); | |
// | |
// Note the dot instead of "->" | |
v = (unsigned int) config.readEntry( .. ) | |
| |
| |
| |
QStringList::split(',', recordStr); | |
==> | |
recordStr.split(,); | |
| |
| |
QVBox *vbox = new QVBox; | |
QPushButton *child1 = new QPushButton(vbox); | |
==> | |
QWidget *vbox = new QWidget; | |
QPushButton *child1 = new QPushButton; | |
// | |
QVBoxLayout *layout = new QVBoxLayout; | |
layout->addWidget(child1); | |
vbox->setLayout(layout); | |
| |
| |
</code> | |
| |
| |