Do you mean that i need to declare it under protected and use it in the constructor ?
No, you need to declare it as a member variable.
Do you know what a member variable is?
{
private: //depends on your needs, this can be any access mode
QextSerialPort *m_note;
public:
Widget
( QWidget *parent
=0,
const char *name
=0 );
private:
int mouse;
int mouseidx;
};
Widget
::Widget( QWidget *parent,
const char *name
)m_note(NULL)
{
setMinimumSize(640,480 );
m_note= new QextSerialPort("/dev/ttyS0");
if(note)
{
m_note->setBaudRate(BAUD115200);
m_note->setParity(PAR_NONE);
m_note->setDataBits(DATA_8);
m_note->setStopBits(STOP_1);
m_note->open(IO_ReadOnly);
}
}
class Widget : public QWidget
{
private: //depends on your needs, this can be any access mode
QextSerialPort *m_note;
public:
Widget( QWidget *parent=0, const char *name=0 );
private:
int mouse;
int mouseidx;
};
Widget::Widget( QWidget *parent, const char *name )
: QWidget( parent, name),
m_note(NULL)
{
setMinimumSize(640,480 );
m_note= new QextSerialPort("/dev/ttyS0");
if(note)
{
m_note->setBaudRate(BAUD115200);
m_note->setParity(PAR_NONE);
m_note->setDataBits(DATA_8);
m_note->setStopBits(STOP_1);
m_note->open(IO_ReadOnly);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks