LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-19-2005, 06:08 PM   #1
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Rep: Reputation: 30
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?

Last edited by spoody_goon; 05-19-2005 at 06:13 PM.
 
Old 05-19-2005, 09:17 PM   #2
spoody_goon
Member
 
Registered: Sep 2003
Location: Michigan USA
Distribution: Mandrake, DamnSmallLinux, VectorLinux
Posts: 416

Original Poster
Rep: Reputation: 30
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);
	
	
}
 
Old 05-24-2005, 06:14 AM   #3
FredKroket
LQ Newbie
 
Registered: May 2005
Posts: 5

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cast from sting to int in Visual C++ Diederick Programming 3 11-29-2005 08:27 AM
how to covert int to string/char type? nelnel Programming 2 08-23-2005 11:46 PM
type cast alaios Programming 2 07-17-2005 04:58 AM
invalid types int[int] for array subscript scuzzman Programming 2 11-16-2004 09:34 PM
Question on type cast cxel91a Programming 2 12-05-2003 09:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration