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

Qt-interest Archive, March 2007
Q_DECLARE_METATYPE error compiling


Message 1 in thread

I have header

#ifndef TFORM_H
#define TFORM_H

#include <QMainWindow>
#include <QtSql>
#include <QDomDocument>
#include <QMetaType>
#include "ui_form.h"

class TForm : public QMainWindow, public Ui::MainWindow
{
     Q_OBJECT

public:
     TForm();
     bool ReadConfig(const QString&);
     bool WriteConfig(const QString&);
     void ScreenCenter();

protected:
public slots:
	void on_btnExec_clicked();
	void on_btnConnect_clicked();
	void on_cbStyles_currentIndexChanged( const QString & text );
protected:
     void closeEvent(QCloseEvent *event);
private:
QSqlDatabase db;
typedef struct MyType
{
     int id;
     QString str;
};
Q_DECLARE_METATYPE(MyType)
};
#endif


why compiler show error ?

TForm.h:34: error: invalid explicit specialization before '>' token
TForm.h:34: error: explicit specialization in non-namespace scope `class 
TForm'
TForm.h:34: error: struct QMetaTypeId<TForm::MyType> redeclared with 
different a
ccess
TForm.h: In static member function `static int 
QMetaTypeId<TForm::MyType>::qt_me
tatype_id()':
TForm.h:34: error: `MyType' undeclared (first use this function)
TForm.h:34: error: (Each undeclared identifier is reported only once for 
each fu
nction it appears in.)
TForm.h:34: error: template argument 1 is invalid
TForm.h:34: error: template argument 1 is invalid
TForm.h:34: error: no matching function for call to 
`qRegisterMetaType(const cha
r[7])'

--
 [ signature omitted ] 

Message 2 in thread

Ok, i found solution:

struct MyType;
Q_DECLARE_METATYPE(MyType)
struct MyType
{
     int id;
     QString str;
};

class TForm : public QMainWindow, public Ui::MainWindow
{
     Q_OBJECT

public:
     TForm();
     bool ReadConfig(const QString&);
     bool WriteConfig(const QString&);
     void ScreenCenter();

protected:
public slots:
	void on_btnExec_clicked();
	void on_btnConnect_clicked();
	void on_cbStyles_currentIndexChanged( const QString & text );
protected:
     void closeEvent(QCloseEvent *event);
private:
QSqlDatabase db;
};
#endif

--
 [ signature omitted ] 

Message 3 in thread

To draw a rubber-band rectangle/line with a CONSTANT color is not a good 
idea,
because it may turn to be invisible due to the same background or the 
same objects color with the pen.
What we need is a pen which inverses the screen pixel color, for example,
pen turns white in black background, and turns black in white background.
I know definitely MFC has such a drawing mode, I wonder if Qt has?

Lingfa


--
 [ signature omitted ] 

Message 4 in thread


    painter.setRasterOp(XorROP);

> -----Original Message-----
> From: qt-interest-request@xxxxxxxxxxxxx
> [mailto:qt-interest-request@xxxxxxxxxxxxx]On Behalf Of Lingfa Yang
> Sent: 23 March 2007 16:38
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Does Qt has a pen to draw XOR screen pixel?
> 
> 
> To draw a rubber-band rectangle/line with a CONSTANT color is not a good 
> idea,
> because it may turn to be invisible due to the same background or the 
> same objects color with the pen.
> What we need is a pen which inverses the screen pixel color, for example,
> pen turns white in black background, and turns black in white background.
> I know definitely MFC has such a drawing mode, I wonder if Qt has?
> 
> Lingfa
> 
> 
> --
> 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 ] 

Message 5 in thread

Gert van Loo wrote:

>    painter.setRasterOp(XorROP);
>  
>
error C2039: 'setRasterOp' : is not a member of 'QPainter'

--
 [ signature omitted ] 

Message 6 in thread

On 23.03.07 14:30:16, Lingfa Yang wrote:
> Gert van Loo wrote:
> 
> >   painter.setRasterOp(XorROP);
> > 
> error C2039: 'setRasterOp' : is not a member of 'QPainter'

I guess thats Qt3. For Qt4 you're looking for the composition mode
(found via scanning the QPainter method list for maybe 30 seconds)

Andreas

-- 
 [ signature omitted ] 

Message 7 in thread

Andreas Pakulat a écrit :
> On 23.03.07 14:30:16, Lingfa Yang wrote:
>   
>> Gert van Loo wrote:
>>
>>     
>>>   painter.setRasterOp(XorROP);
>>>
>>>       
>> error C2039: 'setRasterOp' : is not a member of 'QPainter'
>>     
>
> I guess thats Qt3. For Qt4 you're looking for the composition mode
> (found via scanning the QPainter method list for maybe 30 seconds)
>
> Andreas
>
>   
There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.

--
 [ signature omitted ] 

Message 8 in thread

Hi,

Luper Rouch wrote:
> Andreas Pakulat a écrit :
>> On 23.03.07 14:30:16, Lingfa Yang wrote:
>>  
>>> Gert van Loo wrote:
>>>
>>>    
>>>>   painter.setRasterOp(XorROP);
>>>>
>>>>       
>>> error C2039: 'setRasterOp' : is not a member of 'QPainter'
>>>     
>>
>> I guess thats Qt3. For Qt4 you're looking for the composition mode
>> (found via scanning the QPainter method list for maybe 30 seconds)
>>
>> Andreas
>>
>>   
> There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.

QRubberBand is designed for this purpose in Qt4.

Tim

--
 [ signature omitted ] 

Message 9 in thread

Tim Dewhirst wrote:

> Hi,
>
> Luper Rouch wrote:
>
>> Andreas Pakulat a écrit :
>>
>>> On 23.03.07 14:30:16, Lingfa Yang wrote:
>>>  
>>>
>>>> Gert van Loo wrote:
>>>>
>>>>   
>>>>
>>>>>   painter.setRasterOp(XorROP);
>>>>>
>>>>>       
>>>>
>>>> error C2039: 'setRasterOp' : is not a member of 'QPainter'
>>>>     
>>>
>>>
>>> I guess thats Qt3. For Qt4 you're looking for the composition mode
>>> (found via scanning the QPainter method list for maybe 30 seconds)
>>>
>>> Andreas
>>>
>>>   
>>
>> There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.
>
>
> QRubberBand is designed for this purpose in Qt4.

Thanks Tim,

QRubberBand works for me. It displays a zig-zag white line on a black 
background --- costs 4 pixels in thickness, looks not as nice as a thin 
XOR line. But it does solve my problem, and I have no attention to 
invent a new one.

Thanks,
Lingfa



--
 [ signature omitted ] 

Message 10 in thread

Lingfa Yang wrote:
> Tim Dewhirst wrote:
>
>> Hi,
>>
>> Luper Rouch wrote:
>>
>>> Andreas Pakulat a écrit :
>>>
>>>> On 23.03.07 14:30:16, Lingfa Yang wrote:
>>>>  
>>>>
>>>>> Gert van Loo wrote:
>>>>>
>>>>>  
>>>>>>   painter.setRasterOp(XorROP);
>>>>>>
>>>>>>       
>>>>>
>>>>> error C2039: 'setRasterOp' : is not a member of 'QPainter'
>>>>>     
>>>>
>>>>
>>>> I guess thats Qt3. For Qt4 you're looking for the composition mode
>>>> (found via scanning the QPainter method list for maybe 30 seconds)
>>>>
>>>> Andreas
>>>>
>>>>   
>>>
>>> There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.
>>
>>
>> QRubberBand is designed for this purpose in Qt4.
>
> Thanks Tim,
>
> QRubberBand works for me. It displays a zig-zag white line on a black 
> background --- costs 4 pixels in thickness, looks not as nice as a 
> thin XOR line. But it does solve my problem, and I have no attention 
> to invent a new one.
>
A really nice things about QRubberBand is that its styled. Try it out on 
WindowXP, its a nice alpha blended blue with rounded edges.

The raster ops were take out of Qt because they no longer work on the mac.

--Justin

begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard


Message 11 in thread

Luper Rouch wrote:

> Andreas Pakulat a écrit :
>
>> On 23.03.07 14:30:16, Lingfa Yang wrote:
>>  
>>
>>> Gert van Loo wrote:
>>>
>>>    
>>>
>>>>   painter.setRasterOp(XorROP);
>>>>
>>>>       
>>>
>>> error C2039: 'setRasterOp' : is not a member of 'QPainter'
>>>     
>>
>>
>> I guess thats Qt3. For Qt4 you're looking for the composition mode
>> (found via scanning the QPainter method list for maybe 30 seconds)
>>
>> Andreas
>>
>>   
>
> There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.
>
Yes. I found QPainter::CompositionMode_Xor, which is not the same as the 
bitwise Xor.


--
 [ signature omitted ] 

Message 12 in thread

On 23.03.07 15:11:53, Lingfa Yang wrote:
> Luper Rouch wrote:
> 
> >Andreas Pakulat a écrit :
> >
> >>On 23.03.07 14:30:16, Lingfa Yang wrote:
> >> 
> >>>Gert van Loo wrote:
> >>>
> >>>   
> >>>>  painter.setRasterOp(XorROP);
> >>>>
> >>>>      
> >>>
> >>>error C2039: 'setRasterOp' : is not a member of 'QPainter'
> >>>    
> >>
> >>
> >>I guess thats Qt3. For Qt4 you're looking for the composition mode
> >>(found via scanning the QPainter method list for maybe 30 seconds)
> >>
> >>Andreas
> >>
> >>  
> >
> >There are no bitwise XOR paint operations in Qt4 AFAIK, only alpha XOR.
> >
> Yes. I found QPainter::CompositionMode_Xor, which is not the same as the 
> bitwise Xor.

See the other answer: QRubberBand exists and you don't need to invent
your own.

Andreas

-- 
 [ signature omitted ]