Re: [Interest] qobject_cast

2017-04-20 Thread Thiago Macieira
On quinta-feira, 20 de abril de 2017 09:35:15 PDT Igor Mironchik wrote: > Hi, > > >> QObject has virtual destructor... dynamic_cast will work. But it doesn't > >> matter, the problem was in another... > > > > If your class has virtual functions or derives from such base class, and > > have

Re: [Interest] qobject_cast

2017-04-20 Thread Till Oliver Knoll
> Am 20.04.2017 um 08:05 schrieb nikita baryshnikov : > > Hi, Igor > > Your example is incorrect, cause you forget about Q_OBJECT macro in > Channel class That's what I just wanted to add as a general remark, because it is a common pitfall (at least for me): /every/

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
20.04.2017 19:35, Igor Mironchik пишет: Hi, QObject has virtual destructor... dynamic_cast will work. But it doesn't matter, the problem was in another... If your class has virtual functions or derives from such base class, and have inline (or default) virtual destructor,its v-table will

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
Hi, QObject has virtual destructor... dynamic_cast will work. But it doesn't matter, the problem was in another... If your class has virtual functions or derives from such base class, and have inline (or default) virtual destructor,its v-table will be emitted in each translation unit. This

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
20.04.2017 19:16, Thiago Macieira пишет: On quinta-feira, 20 de abril de 2017 08:47:46 PDT Igor Mironchik wrote: Fix it by adding a non-inline virtual destructor to Channel. Sure. It's just a pseudo code. Then stop pasting pseudo-code. If you hide the problem, then you won't *see* the

Re: [Interest] qobject_cast

2017-04-20 Thread Konstantin Tokarev
20.04.2017, 19:09, "Igor Mironchik" : > 20.04.2017 18:22, Thiago Macieira пишет: >>  Em quarta-feira, 19 de abril de 2017, às 22:56:46 PDT, Igor Mironchik >>  escreveu: >>>  class Channel >>> >>>  : public QObject >>> >>>  {}; >>>  void mySlot() >>>  { >>>  

Re: [Interest] qobject_cast

2017-04-20 Thread Thiago Macieira
On quinta-feira, 20 de abril de 2017 08:47:46 PDT Igor Mironchik wrote: > > Fix it by adding a non-inline virtual destructor to Channel. > > Sure. It's just a pseudo code. Then stop pasting pseudo-code. If you hide the problem, then you won't *see* the problem. > In real code was virtual

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
20.04.2017 18:22, Thiago Macieira пишет: Em quarta-feira, 19 de abril de 2017, às 22:56:46 PDT, Igor Mironchik escreveu: class Channel : public QObject {}; void mySlot() { Channel * ch = qobject_cast< Channel* > ( sender() ); // You are 100% sure that sender() is Channel!!!

Re: [Interest] qobject_cast

2017-04-20 Thread Thiago Macieira
Em quarta-feira, 19 de abril de 2017, às 22:56:46 PDT, Igor Mironchik escreveu: > class Channel > >: public QObject > > {}; > void mySlot() > { >Channel * ch = qobject_cast< Channel* > ( sender() ); >// You are 100% sure that sender() is Channel!!! >// And this cast will

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
Hi, If sender() is a Channel*, then qobject_cast should not fail. Try to add this to your slot, this will print the inheritance list qDebug() << "Looking for" << ::staticMetaObject << Channel::staticMetaObject.className() << "on" << sender() << qobject_cast< Channel* > ( sender() )

Re: [Interest] qobject_cast

2017-04-20 Thread Ch'Gans
On 20 April 2017 at 19:04, Igor Mironchik wrote: > Hi, > > If sender() is a Channel*, then qobject_cast should not fail. > > Try to add this to your slot, this will print the inheritance list > > qDebug() << "Looking for" << ::staticMetaObject << >

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
Hi, If sender() is a Channel*, then qobject_cast should not fail. Try to add this to your slot, this will print the inheritance list qDebug() << "Looking for" << ::staticMetaObject << Channel::staticMetaObject.className() << "on" << sender() << qobject_cast< Channel* > ( sender() )

Re: [Interest] qobject_cast

2017-04-20 Thread Ch'Gans
On 20 April 2017 at 18:10, Igor Mironchik wrote: > > > 20.04.2017 9:01, Ch'Gans пишет: > > On 20 April 2017 at 17:56, Igor Mironchik wrote: > > 20.04.2017 8:47, Ch'Gans пишет: > > On 20 April 2017 at 17:03, Igor Mironchik

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
20.04.2017 9:01, Ch'Gans пишет: On 20 April 2017 at 17:56, Igor Mironchik wrote: 20.04.2017 8:47, Ch'Gans пишет: On 20 April 2017 at 17:03, Igor Mironchik wrote: Hi, 20.04.2017 7:52, Ch'Gans пишет: On 20 April 2017 at 16:38, Igor

Re: [Interest] qobject_cast

2017-04-20 Thread Igor Mironchik
Hi, All is ok with Q_OBJECT in real code. This is just pseudo code... 20.04.2017 9:05, nikita baryshnikov пишет: Hi, Igor Your example is incorrect, cause you forget about Q_OBJECT macro in Channel class On Thu, Apr 20, 2017 at 8:56 AM, Igor Mironchik wrote:

Re: [Interest] qobject_cast

2017-04-20 Thread nikita baryshnikov
Hi, Igor Your example is incorrect, cause you forget about Q_OBJECT macro in Channel class On Thu, Apr 20, 2017 at 8:56 AM, Igor Mironchik wrote: > > > 20.04.2017 8:47, Ch'Gans пишет: > >> On 20 April 2017 at 17:03, Igor Mironchik >> wrote:

Re: [Interest] qobject_cast

2017-04-20 Thread Ch'Gans
On 20 April 2017 at 17:56, Igor Mironchik wrote: > > > 20.04.2017 8:47, Ch'Gans пишет: > >> On 20 April 2017 at 17:03, Igor Mironchik >> wrote: >>> >>> Hi, >>> >>> >>> 20.04.2017 7:52, Ch'Gans пишет: On 20 April 2017 at 16:38, Igor

Re: [Interest] qobject_cast

2017-04-19 Thread Igor Mironchik
20.04.2017 8:47, Ch'Gans пишет: On 20 April 2017 at 17:03, Igor Mironchik wrote: Hi, 20.04.2017 7:52, Ch'Gans пишет: On 20 April 2017 at 16:38, Igor Mironchik wrote: Hi, What the benefits of qobject_cast<> on simple static_cast<>? Or

Re: [Interest] qobject_cast

2017-04-19 Thread Thiago Macieira
On quarta-feira, 19 de abril de 2017 21:38:46 PDT Igor Mironchik wrote: > Hi, > > What the benefits of qobject_cast<> on simple static_cast<>? Or there is > no one? qobject_cast checks, static_cast doesn't. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open

Re: [Interest] qobject_cast

2017-04-19 Thread Ch'Gans
On 20 April 2017 at 17:03, Igor Mironchik wrote: > Hi, > > > 20.04.2017 7:52, Ch'Gans пишет: >> >> On 20 April 2017 at 16:38, Igor Mironchik >> wrote: >>> >>> Hi, >>> >>> What the benefits of qobject_cast<> on simple static_cast<>? Or there is

Re: [Interest] qobject_cast

2017-04-19 Thread Igor Mironchik
Hi, 20.04.2017 7:52, Ch'Gans пишет: On 20 April 2017 at 16:38, Igor Mironchik wrote: Hi, What the benefits of qobject_cast<> on simple static_cast<>? Or there is no qobject_cast - works only on QObject (obviously) - returns nullptr if the object cannot be casted

Re: [Interest] qobject_cast

2017-04-19 Thread Ch'Gans
On 20 April 2017 at 16:38, Igor Mironchik wrote: > Hi, > > What the benefits of qobject_cast<> on simple static_cast<>? Or there is no qobject_cast - works only on QObject (obviously) - returns nullptr if the object cannot be casted to the required type - doesn't relies

[Interest] qobject_cast

2017-04-19 Thread Igor Mironchik
Hi, What the benefits of qobject_cast<> on simple static_cast<>? Or there is no one? ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest

Re: [Interest] qobject_cast returns 0

2017-01-27 Thread Alexander Dyagilev
Thank you! That was the reason. On 1/27/2017 11:32 PM, Konstantin Shegunov wrote: Have you exported your class (and thus all its mata object information) from said dll? ___ Interest mailing list Interest@qt-project.org

Re: [Interest] qobject_cast returns 0

2017-01-27 Thread Konstantin Shegunov
Have you exported your class (and thus all its mata object information) from said dll? ___ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest

Re: [Interest] qobject_cast returns 0

2017-01-27 Thread Alexander Dyagilev
it seems the problem is that class instance is created in one DLL while qobject_cast is called for this instance in another DLL... can this be the reason? what can be done then? On 1/27/2017 11:24 PM, Alexander Dyagilev wrote: Hello, got one yet another qt bug(?)

[Interest] qobject_cast returns 0

2017-01-27 Thread Alexander Dyagilev
Hello, got one yet another qt bug(?) qobject_cast returns 0 dynamic_cast works fine. MyClass is derived from a base class derived from QObject. Q_OBJECT macro is present... ___ Interest mailing list Interest@qt-project.org

Re: [Interest] qobject_cast, static libraries and plugins

2013-08-09 Thread Thiago Macieira
On sexta-feira, 9 de agosto de 2013 17:47:12, Jan Kundrát wrote: Hi, it looks that I cannot use qobject_cast in the following scenario: 0) Everything is built with -fPIC 1) class Foo: public QObject is defined in a *static* library libCommon Let me stop here. Before reading the rest, I can