| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 3 | |
hi all,
plz try to answer my question...
Mystring = "qt'\t'is'\t'trolltech'\t'product" which is equivanat to "qt is trolltech product"
if i use Mystring.length() iam getting value = 23 but ,actual is 40, qt is considering '\t'(tab space ) as sigle charector, but its value varies depends upon position.
i want to consider '\t' size like
if '\t' is at 7th position size for that '\t' is 1
if '\t' is at 6th position size for that '\t' is 2
if '\t' is at 4th position size for that '\t' is 3
if '\t' is at 3th position size for that '\t' is 4
if '\t' is at 2th position size for that '\t' is 5 etc..
is there any function provided by to solve my purpose,
and give me suggestions to solve.
futher clarification abut my problem plz send me mail..
D. Anil kumar
Every success has a story of great failure.
So don't stop with failure where
Success comes after failure.
anil kumar schrieb: > hi all, > plz try to answer my question... > Mystring = "qt'\t'is'\t'trolltech'\t'product" which is equivanat to > "qt is trolltech product" > if i use Mystring.length() iam getting value = 23 but ,actual is 40, qt > is considering '\t'(tab space ) as sigle charector, but its value varies > depends upon position. > > i want to consider '\t' size like > if '\t' is at 7th position size for that '\t' is 1 > if '\t' is at 6th position size for that '\t' is 2 > if '\t' is at 4th position size for that '\t' is 3 > if '\t' is at 3th position size for that '\t' is 4 > if '\t' is at 2th position size for that '\t' is 5 etc.. > is there any function provided by to solve my purpose, > and give me suggestions to solve. > [...] This - is not related to Qt in any way - depends on the intended tab width - is kind of trivial And therefor the solution is left as an exercise to the reader. :-) If you insist in re-using code, maybe take a look at the sources for the Unix command "expand". > D. Anil kumar > > Every success has a story of great failure. > So don’t stop with failure where > Success comes after failure. How true. Might apply to your current problem also? SCNR ... Best Regards / Mit freundlichen Grüßen Rainer Wiesenfarth -- [ signature omitted ]
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
> if i use Mystring.length() iam getting value = 23 but ,actual is 40, > qt is considering '\t'(tab space ) as sigle charector, but its value > varies depends upon position. the Tab "\t" _IS_ exactly ONE character. So Mystring.length() is working exactly the way it is expected to! Whatever you display on screen is up to you. If you want to do some "replace tabs by spaces" -> that's your job ;-) Regards, Malte -- [ signature omitted ]
i cant replace with '\t' with spaces because if '\t' presents at 9th position then it posses 7 spaces, if it presents 27th possition it posses 5 spaces , so depending upon the position that has , correspanding number of spaces i will contain... plz give me how to solve this problem... D. Anil kumar Every success has a story of great failure. So don't stop with failure where Success comes after failure. ----- Original Message ----- From: "Malte Witt" <malte.witt@xxxxxxxxxxxxx> To: <qt-interest@xxxxxxxxxxxxx> Sent: Thursday, May 10, 2007 12:13 PM Subject: Re: How can i find the length of string contains that tabspaces > > if i use Mystring.length() iam getting value = 23 but ,actual is 40, > > qt is considering '\t'(tab space ) as sigle charector, but its value > > varies depends upon position. > > the Tab "\t" _IS_ exactly ONE character. So Mystring.length() is working > exactly the way it is expected to! > Whatever you display on screen is up to you. If you want to do some > "replace tabs by spaces" -> that's your job ;-) > > Regards, > Malte > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ > > -- [ signature omitted ]
This is NOT a QT issue. It is basic C++. I do not understand, why should these questions be posted in a QT forum. The C++ std lib string lenght function also behaves in the same way. Why dont you try C++ forums ? I think this is not the place to discuss non-QT C++ issues. --Prateek -----Original Message----- From: anil kumar [mailto:d.anil@xxxxxxxxxxxxx] Sent: Thursday, May 10, 2007 12:27 PM To: Malte Witt; qtForum Subject: Re: How can i find the length of string contains that tabspaces i cant replace with '\t' with spaces because if '\t' presents at 9th position then it posses 7 spaces, if it presents 27th possition it posses 5 spaces , so depending upon the position that has , correspanding number of spaces i will contain... plz give me how to solve this problem... D. Anil kumar Every success has a story of great failure. So don't stop with failure where Success comes after failure. ----- Original Message ----- From: "Malte Witt" <malte.witt@xxxxxxxxxxxxx> To: <qt-interest@xxxxxxxxxxxxx> Sent: Thursday, May 10, 2007 12:13 PM Subject: Re: How can i find the length of string contains that tabspaces > > if i use Mystring.length() iam getting value = 23 but ,actual is 40, > > qt is considering '\t'(tab space ) as sigle charector, but its value > > varies depends upon position. > > the Tab "\t" _IS_ exactly ONE character. So Mystring.length() is > working exactly the way it is expected to! > Whatever you display on screen is up to you. If you want to do some > "replace tabs by spaces" -> that's your job ;-) > > Regards, > Malte > > -- > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. > List archive and information: http://lists.trolltech.com/qt-interest/ > > -- [ signature omitted ]
> i cant replace with '\t' with spaces because if '\t' presents at 9th > position then it posses 7 spaces, if it presents 27th possition it posses 5 > spaces , so depending upon the position that has , correspanding number of > spaces i will contain... > plz give me how to solve this problem... I really CANNOT see any problem here ... Why don't you write a method which "calculates" the number of spaces for a tab? Depending on your requirements you could then go ahead and replace the tabs or just take the number and be happy ... Doesn't seem to be very complicated to me - am I getting something wrong? Regards, Malte -- [ signature omitted ]
anil kumar schrieb: > i cant replace with '\t' with spaces because if '\t' presents at 9th > position then it posses 7 spaces, if it presents 27th possition it posses 5 > spaces , so depending upon the position that has , correspanding number of > spaces i will contain... > [...] Wrong, as I use a tab width of 4, the \t at 9th position represents 3 spaces, and the one at 27th position 1 - but only if there was no \t before. The algorithm is trivial and straightforward, so I will _not_ give it to you. Sit down and think over it, you will learn more than only getting the solution for your current problem. ... and change your signature, as you yourself do not go the way of failure ... Best Regards / Mit freundlichen Grüßen Rainer Wiesenfarth -- [ signature omitted ]
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
Hmmm, I want tabs at every half-inch, which changes depending on font size and name. However, the width of character 9 depends on the font. When measuring a string, 'tab' is just another character that may or may not be displayable. Thinking that a tab is replaced by spaces is fine for character terminals, but not GUI environments (display length measurements). If your tab is replaced, then do the replacing before you measure the length. Keith **Please do not reply to me, reply to the list.** On 05-10-2007 2:07 AM, "Rainer Wiesenfarth" wrote: > anil kumar schrieb: >> i cant replace with '\t' with spaces because if '\t' presents at 9th >> position then it posses 7 spaces, if it presents 27th possition it posses 5 >> spaces , so depending upon the position that has , correspanding number of >> spaces i will contain... >> [...] > > Wrong, as I use a tab width of 4, the \t at 9th position represents 3 > spaces, and the one at 27th position 1 - but only if there was no \t before. > > The algorithm is trivial and straightforward, so I will _not_ give it to > you. Sit down and think over it, you will learn more than only getting > the solution for your current problem. > > ... and change your signature, as you yourself do not go the way of > failure ... > > Best Regards / Mit freundlichen Grüßen > Rainer Wiesenfarth -- [ signature omitted ]