Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-07 Thread Eric Clark
 -Original Message-
 From: interest-bounces+eclark=ara@qt-project.org [mailto:interest-
 bounces+eclark=ara@qt-project.org] On Behalf Of Thiago Macieira
 Sent: Friday, April 04, 2014 6:04 PM
 To: interest@qt-project.org
 Subject: Re: [Interest] QFileInfoList inheritance producing warnings
 
 Em sex 04 abr 2014, às 21:20:23, Eric Clark escreveu:
  I have worked around the warnings by using a QVector instead, but it
  would still be nice to know why QList is producing all of these warnings...
 
 It's not QList, it's MSVC.
 
 I assume you added an export clause to your class, right? When you do that,
 MSVC tries to instantiate all methods in the class, which is what caused it to
 emit that warning.

That makes a lot of sense. Sometimes MSVC can be such a pain in the you know 
what. Thank you for the response Thiago!

 
 Other compilers, more compliant with the C++ standard, won't say anything.
 
 I recommend simply silencing the warning.
 --
 Thiago Macieira - thiago.macieira (AT) intel.com
   Software Architect - Intel Open Source Technology Center
 
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Guido Seifert

 Hello All,
 
 I am in the process of creating a class that I would like to inherit 
 QFileInfoList.


Four words: Do not do it. QList's destructor not virtual - not meant for 
inheritance.

Guido
 
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread André Somers


 Op 4 apr. 2014 om 21:38 heeft Guido Seifert warg...@gmx.de het volgende 
 geschreven:
 
 
 Hello All,
 
 I am in the process of creating a class that I would like to inherit 
 QFileInfoList.
 
 
 Four words: Do not do it. QList's destructor not virtual - not meant for 
 inheritance.

Well, you _can_, as long as you only add methods and no members. Qt does it 
too, with QQueue and QStack for instance. It can be convenient to add some nice 
API.

André

 
 Guido
 
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Eric Clark

From: interest-bounces+eclark=ara@qt-project.org 
[interest-bounces+eclark=ara@qt-project.org] on behalf of Guido Seifert 
[warg...@gmx.de]
Sent: Friday, April 04, 2014 2:38 PM
To: interest@qt-project.org
Subject: Re: [Interest] QFileInfoList inheritance producing warnings

 Hello All,

 I am in the process of creating a class that I would like to inherit 
 QFileInfoList.


 Four words: Do not do it. QList's destructor not virtual - not meant for 
 inheritance.

I am sorry, but are there any Qt developers (or anyone with a better answer or 
at least an explanation of why not to do it) out there that could answer this 
question for me? If it was not intended to be inherited, then please explain to 
me why Qt can do it without problems? As an example, QStringList does exactly 
this (it is a prefect example of a class that inherits QListQString).

 Guido

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Eric Clark
Thank you for the responses that I did get. I still have not solved the 
problem, but switching to QVector instead of QList seems to have gotten rid of 
the warnings.

Thanks,
Eric

From: interest-bounces+eclark=ara@qt-project.org 
[interest-bounces+eclark=ara@qt-project.org] on behalf of Eric Clark 
[ecl...@ara.com]
Sent: Friday, April 04, 2014 3:17 PM
To: interest@qt-project.org
Subject: Re: [Interest] QFileInfoList inheritance producing warnings


From: interest-bounces+eclark=ara@qt-project.org 
[interest-bounces+eclark=ara@qt-project.org] on behalf of Guido Seifert 
[warg...@gmx.de]
Sent: Friday, April 04, 2014 2:38 PM
To: interest@qt-project.org
Subject: Re: [Interest] QFileInfoList inheritance producing warnings

 Hello All,

 I am in the process of creating a class that I would like to inherit 
 QFileInfoList.


 Four words: Do not do it. QList's destructor not virtual - not meant for 
 inheritance.

I am sorry, but are there any Qt developers (or anyone with a better answer or 
at least an explanation of why not to do it) out there that could answer this 
question for me? If it was not intended to be inherited, then please explain to 
me why Qt can do it without problems? As an example, QStringList does exactly 
this (it is a prefect example of a class that inherits QListQString).

 Guido

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Guido Seifert

 Well, you _can_, as long as you only add methods and no members. Qt does it 
 too, with QQueue and QStack for instance. 
 It can be convenient to add some nice API.

You can, but you should not. Convenient can also be interpreted as lazy. ;-)
I would use a composition approach. Deemed to be more flexible. Why 
inheritance was used in QQueue and QStack? Simpler code? Better readability? 
Performance reasons? No idea. If someone can give a reason, it is probably
Thiago. :-D

Guido
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Eric Clark


 -Original Message-
 From: interest-bounces+eclark=ara@qt-project.org [mailto:interest-
 bounces+eclark=ara@qt-project.org] On Behalf Of Guido Seifert
 Sent: Friday, April 04, 2014 3:58 PM
 Cc: interest@qt-project.org
 Subject: Re: [Interest] QFileInfoList inheritance producing warnings
 
 
  Well, you _can_, as long as you only add methods and no members. Qt
 does it too, with QQueue and QStack for instance.
  It can be convenient to add some nice API.
 
 You can, but you should not. Convenient can also be interpreted as lazy. ;-) I
 would use a composition approach. Deemed to be more flexible. Why
 inheritance was used in QQueue and QStack? Simpler code? Better
 readability?

I can completely see where you are coming from here Guido, but there is also a 
very good reason
to use inheritance other than being lazy. I mean we are all coders right? 
Were we not taught that
software reuse is a must and NEVER to reinvent the wheel? Yes, composition will 
give me the same
functionality, but it will NOT give me the methods that are provided with the 
class I inherit. Therefore,
if I want to replicate those methods, is it really better to rewrite them all 
and just call the same method
in the object that is now composed instead of inherited? Yes, I can inline 
these calls and the compiler 
should be smart enough to inline the calls for performance, but why should I 
have to rewrite 50 different
methods just to call the same exact methods in the class?

I would guess that the reason the class was not written with any virtual 
methods was for performance (and, 
yes I know that this is a pretty large increase in performance), but I don't 
need a virtual destructor, nor do I need
any virtual methods, I just want to add some extra methods to this particular 
array to make coding easier on our
developers. The Qt developers have done it; therefore, they obviously see the 
benefit... just trying to figure
out why I can't do it...

I have worked around the warnings by using a QVector instead, but it would 
still be nice to know why QList
is producing all of these warnings...

I really appreciate your feedback by the way!
Eric

 Performance reasons? No idea. If someone can give a reason, it is probably
 Thiago. :-D
 
 Guido
 ___
 Interest mailing list
 Interest@qt-project.org
 http://lists.qt-project.org/mailman/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Sue, Michael
You'd have to show more of your code to make sure what the actual problem is, 
not just the error message. As it is I can only assume it's a missing C++11 
feature that VS 2010 would need to easily re-use the class QList.
-Michael.


___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Thiago Macieira
Em sex 04 abr 2014, às 22:58:02, Guido Seifert escreveu:
 You can, but you should not. Convenient can also be interpreted as lazy. ;-)
 I would use a composition approach. Deemed to be more flexible. Why
 inheritance was used in QQueue and QStack? Simpler code? Better
 readability? Performance reasons? No idea. If someone can give a reason, it
 is probably Thiago. :-D

Homer Simpson rule #1:
It was like that when I arrived.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Thiago Macieira
Em sex 04 abr 2014, às 21:20:23, Eric Clark escreveu:
 I have worked around the warnings by using a QVector instead, but it would
 still be nice to know why QList is producing all of these warnings...

It's not QList, it's MSVC.

I assume you added an export clause to your class, right? When you do that, 
MSVC tries to instantiate all methods in the class, which is what caused it to 
emit that warning.

Other compilers, more compliant with the C++ standard, won't say anything.

I recommend simply silencing the warning.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] QFileInfoList inheritance producing warnings

2014-04-04 Thread Thiago Macieira
Em sex 04 abr 2014, às 16:01:18, Thiago Macieira escreveu:
 Em sex 04 abr 2014, às 22:58:02, Guido Seifert escreveu:
  You can, but you should not. Convenient can also be interpreted as lazy.
  ;-) I would use a composition approach. Deemed to be more flexible. Why
  inheritance was used in QQueue and QStack? Simpler code? Better
  readability? Performance reasons? No idea. If someone can give a reason,
  it
  is probably Thiago. :-D
 
 Homer Simpson rule #1:
 It was like that when I arrived.

Oops, I got the order and the quote wrong. It's rule 3:
It was like that when I got here!

http://www.aaaugh.com/jokes/homer_simpson.html
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest