LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   type cast from int to QString (https://www.linuxquestions.org/questions/programming-9/type-cast-from-int-to-qstring-325154/)

spoody_goon 05-19-2005 06:08 PM

type cast from int to QString
 
I am a windows programmer looking to get started in Linux. I have chosen kdevelop and qt to design and code. How big is the learning curve when moving from a msdn enviroment to a Linux enviroment?

I could use any resourses for kdevelop and qt that anyone may have, I have a few already but you can never have enough.

Now for the big question I am goofing with a turorial and I need to know how to type case from an int to a QString?

Code:

#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
#include "sigcreate.h"

SigCreate::SigCreate(QWidget* parent, const char* name, WFlags fl)
    : Form1(parent,name,fl)
{}

SigCreate::~SigCreate()
{}

/*$SPECIALIZATION$*/
void SigCreate::slotCreateSig()
{
        QString TestString;
        int StringLength;
       
        TestString = nameBox->text();
        StringLength = TestString.length();
       
        sigBox->setText(TestString);
        sigBox->append("\n--");
        // sigBox->append(Cstr(StringLenght));
}

Does my windoz experiance hang out?

spoody_goon 05-19-2005 09:17 PM

Got it if anyone else wants to know use QVariant like so:

Code:

#include <qlineedit.h>
#include <qcombobox.h>
#include <qmultilineedit.h>
// ADDED THIS
#include <qvariant.h>
#include "sigcreate.h"

SigCreate::SigCreate(QWidget* parent, const char* name, WFlags fl)
    : Form1(parent,name,fl)
{}

SigCreate::~SigCreate()
{}

/*$SPECIALIZATION$*/
void SigCreate::slotCreateSig()
{
        QString TestString;
      // ADDED THIS
        QVariant StringLength;
        QString CastedString;
       
        TestString = nameBox->text();
        StringLength = TestString.length();
        CastedString = StringLength.toString();
       
        sigBox->setText(TestString);
        sigBox->append("\n--");
        sigBox->append(CastedString);
       
       
}


FredKroket 05-24-2005 06:14 AM

Whaaat? Just use the static function QString::number(yourInteger), which also works with doubles / longs etc....


All times are GMT -5. The time now is 03:43 PM.