Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, April 2007
Object constructed when a QValueList declared


Message 1 in thread

Hi all,

I am a newbie in QT.  I am trying to use a QValueList, but I found QT 
constructed the class when a QValueList variable is declared.  Here is the 
sample:

#include <iostream>
#include <vector>
#include <qvaluelist.h>

using namespace std;

class A
{
 public:
  A():i(0) { cout << "A constructed \n"; };
  virtual ~A() { cout << "A destructed\n "; };
  int i;
};

typedef QValueList< A > AList;
typedef vector < A >    AVector;

int main(void) {

 cout << "alist\n";
 AList alist;
 cout << "avec\n";
 AVector avec;
 cout << "end\n";

 return 0;

}

Output:
alist
A constructed
avec
end
A destructed

Is it supposed to be like that?  Please note STL vector does not do that.

Thank you in advanced.

Siman 


--
 [ signature omitted ] 

Message 2 in thread

I'd like to do things like replace "Bob<paragraph>Ray" with 
"Gene<paragraph>Glenn".

The find function doesn't seem to think much of "\n", and messing about 
with #10 and #13 didn't help either.

Is there any simple way of doing this, or must I break up my strings and 
use QTextCursor and .atBlockEnd()?

--
 [ signature omitted ] 

Message 3 in thread

On Thursday 05 April 2007 03:50:34 siman hew wrote:
> Hi all,
>
> I am a newbie in QT.  I am trying to use a QValueList, but I found QT
> constructed the class when a QValueList variable is declared.  Here is the
> sample:
>
> #include <iostream>
> #include <vector>
> #include <qvaluelist.h>
>
> using namespace std;
>
> class A
> {
>  public:
>   A():i(0) { cout << "A constructed \n"; };
>   virtual ~A() { cout << "A destructed\n "; };
>   int i;
> };
>
> typedef QValueList< A > AList;
> typedef vector < A >    AVector;
>
> int main(void) {
>
>  cout << "alist\n";
>  AList alist;
>  cout << "avec\n";
>  AVector avec;
>  cout << "end\n";
>
>  return 0;
>
> }
>
> Output:
> alist
> A constructed
> avec
> end
> A destructed
>
> Is it supposed to be like that?  Please note STL vector does not do that.

Yes, that is a known limitation of QValueList in Qt 3 that has been removed in 
Qt 4's container classes.


Simon

Attachment:

Attachment: pgpTmQ8Xet8Ub.pgp
Description: PGP signature