[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: [PyQt] another question with template inheritance
From: Denis Rouzaud <denis.rouzaud () gmail ! com>
Date: 2017-05-22 13:02:15
Message-ID: CAMtsY+Zmqcw522c836xTkwDJNGHzLOG+1Q2rydYMXOOnvVNS7w () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Dear all,
I have another issue with template based inheritance.
Let's say I have the header
template <typename T>
class QgsTemporalRange
{
public:
QgsTemporalRange( const T &begin = T(), const T &end = T() );
};
typedef QgsTemporalRange< QDate > QgsDateRange;
And the SIP file:
template <T>
class QgsTemporalRange
{
%TypeHeaderCode
#include "qgsrange.h"
%End
public:
QgsTemporalRange( const T &begin = T(), const T &end = T() );
};
typedef QgsTemporalRange< QDate > QgsDateRange;
I get the following error in the generated cpp code in
static void *init_type_QgsDateRange(sipSimpleWrapper *, PyObject
*sipArgs, PyObject *sipKwds, PyObject **sipUnused, PyObject **,
PyObject **sipParseErr)
at line:
const QDate& a0def = T();
:: error: use of undeclared identifier 'T'
I gave it a try by using classes instead of typedef (as described in
[0]) but it leads to exactly the same error (which is logic I guess).
Any idea how to solve this?
Thanks a lot,
Denis
[0] https://www.riverbankcomputing.com/pipermail/pyqt/2017-May/039188.html
[Attachment #5 (text/html)]
<div dir="ltr">Dear all,<div><br></div><div>I have another issue with template based \
inheritance.</div><div><br></div><div>Let's say I have the \
header</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">template</span><span style="color:rgb(192,192,192)"> \
</span><<span style="color:rgb(128,128,0)">typename</span><span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">T</span>></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span></pre> <pre \
style="margin-top:0px;margin-bottom:0px">{</pre> <pre \
style="margin-top:0px;margin-bottom:0px"> <span \
style="font-family:sans-serif;color:rgb(128,128,0)">public</span><span \
style="font-family:sans-serif">:</span></pre> <pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span>(<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span><span \
style="color:rgb(192,192,192)"> </span>&begin<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span>(),<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span><span \
style="color:rgb(192,192,192)"> </span>&end<span style="color:rgb(192,192,192)"> \
</span>=<span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">T</span>() );</pre><pre \
style="margin-top:0px;margin-bottom:0px">};</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">typedef</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span><<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">QDate</span><span style="color:rgb(192,192,192)"> \
</span>><span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">QgsDateRange</span>;</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px">And the SIP file:</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><pre \
style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">template</span><span style="color:rgb(192,192,192)"> \
</span><<span style="color:rgb(128,0,128)">T</span>></pre><pre \
style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span></pre><pre \
style="margin-top:0px;margin-bottom:0px">{</pre><pre \
style="margin-top:0px;margin-bottom:0px">%TypeHeaderCode #include \
"qgsrange.h" %End
</pre><div><span style="font-family:sans-serif"> </span><span \
style="font-family:sans-serif;color:rgb(128,128,0)">public</span><span \
style="font-family:sans-serif">:</span><br></div><pre \
style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span>(<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span><span \
style="color:rgb(192,192,192)"> </span>&begin<span \
style="color:rgb(192,192,192)"> </span>=<span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span>(),<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,128,0)">const</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">T</span><span \
style="color:rgb(192,192,192)"> </span>&end<span style="color:rgb(192,192,192)"> \
</span>=<span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">T</span>() );</pre><pre \
style="margin-top:0px;margin-bottom:0px">};</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><span \
style="color:rgb(128,128,0)">typedef</span><span style="color:rgb(192,192,192)"> \
</span><span style="color:rgb(128,0,128)">QgsTemporalRange</span><<span \
style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">QDate</span><span style="color:rgb(192,192,192)"> \
</span>><span style="color:rgb(192,192,192)"> </span><span \
style="color:rgb(128,0,128)">QgsDateRange</span>;</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px">I get the following error in the generated \
cpp code in </pre><pre style="margin-top:0px;margin-bottom:0px">static void \
*init_type_QgsDateRange(sipSimpleWrapper *, PyObject *sipArgs, PyObject *sipKwds, \
PyObject **sipUnused, PyObject **, PyObject **sipParseErr)<br></pre><pre \
style="margin-top:0px;margin-bottom:0px">at line:<br></pre><pre \
style="margin-top:0px;margin-bottom:0px">const QDate& a0def = T();</pre><pre \
style="margin-top:0px;margin-bottom:0px">:: error: use of undeclared identifier \
'T'<br></pre></pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px">I gave it a try by using classes instead of \
typedef (as described in [0]) but it leads to exactly the same error (which is logic \
I guess).<br></pre><pre style="margin-top:0px;margin-bottom:0px">Any idea how to \
solve this?</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px">Thanks a lot,</pre><pre \
style="margin-top:0px;margin-bottom:0px">Denis</pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre><pre \
style="margin-top:0px;margin-bottom:0px">[0] <a \
href="https://www.riverbankcomputing.com/pipermail/pyqt/2017-May/039188.html">https://www.riverbankcomputing.com/pipermail/pyqt/2017-May/039188.html</a></pre><pre \
style="margin-top:0px;margin-bottom:0px"><br></pre></div></div>
[Attachment #6 (text/plain)]
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic