PDA

View Full Version : embedded why error QWSMouseHandler



Thành Viên Mới
24th May 2011, 12:10
this is my code use, but it cant build error:cannot declare variable to be of abstract type 'QWSMouseHandler

can you help me ?




#if defined(Q_OS_LINUX)
QPoint qpoint = QWSMouseHandler::pos();
Qt::MouseButtons buttons = Qt::NoButton;
if (qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
{
if (event->key() == Qt::Key_Left)
{
qpoint.setX(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Up)
{
qpoint.setY(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Down)
{
qpoint.setX(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Right)
{
qpoint.setY(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
{
buttons |= Qt::LeftButton;
}
QWSMouseHandler::mouseChanged (qpoint,buttons,0);
//QWSServer::sendMouseEvent( qpoint, 0 );
}
#else



src/BrowserWindow.cpp:101: error: cannot declare variable 'qwsMouse' to be of abstract type 'QWSMouseHandler'
../../../../install/include/QtGui/qmouse_qws.h:67: note: because the following virtual functions are pure within 'QWSMouseHandler':
../../../../install/include/QtGui/qmouse_qws.h:77: note: virtual void QWSMouseHandler::resume()
../../../../install/include/QtGui/qmouse_qws.h:78: note: virtual void QWSMouseHandler::suspend()
src/BrowserWindow.cpp:127: error: no matching function for call to 'QWSMouseHandler::mouseChanged(QPoint*, Qt::MouseButtons&, int)'
../../../../install/include/QtGui/qmouse_qws.h:81: note: candidates are: void QWSMouseHandler::mouseChanged(const QPoint&, int, int)
make: *** [BrowserWindow.o] Error 1

Santosh Reddy
24th May 2011, 13:49
The error means that the "QWSMouseHandler" is not a complete type, to make it complete you need to implement the pure virtual functions. You need to subclass "QWSMouseHandler" and then implement them, use it.

The last error is regarding the datatype mismatch, that should be simple

Thành Viên Mới
25th May 2011, 09:13
The error means that the "QWSMouseHandler" is not a complete type, to make it complete you need to implement the pure virtual functions. You need to subclass "QWSMouseHandler" and then implement them, use it.

The last error is regarding the datatype mismatch, that should be simple

yeah, but when i subclass it then error



class QMouse : public QWSMouseHandler
{
public:
explicit QMouse(const QString &driver = QString(),const QString &device = QString());
void mouseChanged ( const QPoint & position, int state, int wheel = 0 );
const QPoint & pos () ;
};
void BrowserWindow::keyReleaseEvent(QKeyEvent *event)
{
#if defined(Q_OS_LINUX)
QPoint qpoint = QMouse::pos();
Qt::MouseButtons buttons = Qt::NoButton;
if (qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
{
if (event->key() == Qt::Key_Left)
{
qpoint.setX(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Up)
{
qpoint.setY(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Down)
{
qpoint.setX(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Right)
{
qpoint.setY(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
{
buttons |= Qt::LeftButton;
}
QMouse::mouseChanged (qpoint,buttons,0);




can you help me ?

src/BrowserWindow.cpp: In member function 'virtual void BrowserWindow::keyReleaseEvent(QKeyEvent*)':
src/BrowserWindow.cpp:115: error: cannot call member function 'const QPoint& QMouse::pos()' without object
src/BrowserWindow.cpp:139: error: cannot call member function 'void QMouse::mouseChanged(const QPoint&, int, int)' without object
make: *** [BrowserWindow.o] Error 1


Added after 12 minutes:


class QMouse : public QWSMouseHandler
{
public:
explicit QMouse(const QString &driver = QString(),const QString &device = QString());
void mouseChanged ( const QPoint & position, int state, int wheel = 0 );
const QPoint & pos () ;
void resume ();
void suspend ();
};

#endif
void BrowserWindow::keyReleaseEvent(QKeyEvent *event)
{
#if defined(Q_OS_LINUX)
QMouse* qmouseSonnh;
qmouseSonnh = new QMouse;
QPoint qpoint = qmouseSonnh->pos();
Qt::MouseButtons buttons = Qt::NoButton;
if (qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
{
if (event->key() == Qt::Key_Left)
{
qpoint.setX(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Up)
{
qpoint.setY(qpoint.x() + 30);
}
if (event->key() == Qt::Key_Down)
{
qpoint.setX(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Right)
{
qpoint.setY(qpoint.x() - 30);
}
if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return)
{
buttons |= Qt::LeftButton;
}
qmouseSonnh->mouseChanged (qpoint,buttons,0);
//QWSServer::sendMouseEvent( qpoint, 0 );
}
#else
int delta = 50;
QPoint pos = QCursor::pos();
switch (event->key())
{
case Qt::Key_Left:
pos.rx() -= delta;
break;
case Qt::Key_Right:
pos.rx() += delta;
break;
case Qt::Key_Up:
pos.ry() -= delta;
break;
case Qt::Key_Down:
pos.ry() += delta;
break;
case Qt::Key_Return:
break;
default:
break;
}
QCursor::setPos(pos);
#endif
QWidget::keyReleaseEvent(event);
switch (event->key())
{
case Qt::Key_Home:
if (m_animation->state() == QAbstractAnimation::Running)
{
const QAbstractAnimation::Direction direction = m_animation->direction() == QAbstractAnimation::Forward
? QAbstractAnimation::Forward
: QAbstractAnimation::Backward;
m_animation->setDirection(direction);
}
else if (qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
{
showHomeView();
}
else
{
showBrowserView();
}
case Qt::Key_F1:
if (!qFuzzyCompare(slideValue(), static_cast<qreal>(1.0f)))
{
m_homeView->SetBookMark();
}
break;
default:
return;
}
event->accept();
}


BrowserWindow.o:/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:106: undefined reference to `QMouse::pos()'
BrowserWindow.o:/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:106: undefined reference to `QMouse::pos()'
BrowserWindow.o:/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:130: undefined reference to `QMouse::mouseChanged(QPoint const&, int, int)'
BrowserWindow.o:/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:130: undefined reference to `QMouse::mouseChanged(QPoint const&, int, int)'
BrowserWindow.o: In function `BrowserWindow':
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:35: undefined reference to `QMouse::QMouse(QString const&, QString const&)'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:35: undefined reference to `QMouse::QMouse(QString const&, QString const&)'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:35: undefined reference to `QMouse::QMouse(QString const&, QString const&)'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/web-browser-sonnh89-24-5-2011/src/BrowserWindow.cpp:35: undefined reference to `QMouse::QMouse(QString const&, QString const&)'

Santosh Reddy
25th May 2011, 09:35
QPoint qpoint = qmouseSonnh->pos();
qmouseSonnh->mouseChanged (qpoint,buttons,0);

with this modification it should compile, if not try clean build

Thành Viên Mới
25th May 2011, 09:46
yeah, i cleaned project, but error:

BrowserWindow.o: In function `QMouse':
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: undefined reference to `vtable for QMouse'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: undefined reference to `vtable for QMouse'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: undefined reference to `vtable for QMouse'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: undefined reference to `vtable for QMouse'
/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: undefined reference to `vtable for QMouse'
BrowserWindow.o:/tango3/qt_SMP8654F_bin_4.5.2-1.1/src/demos/embedded/123/src/BrowserWindow.h:20: more undefined references to `vtable for QMouse' follow
collect2: ld returned 1 exit status

high_flyer
25th May 2011, 11:45
Are you trying to use signals and slots withe QMouse?
And show the implementation of QMouse.

Santosh Reddy
26th May 2011, 07:41
Did you implement the following virtual methods? (just in case, you missed them)


class QMouse : public QWSMouseHandler
{
public:
explicit QMouse(const QString &driver = QString(),const QString &device = QString());
void mouseChanged ( const QPoint & position, int state, int wheel = 0 );
const QPoint & pos () ;// ?
void resume ();// ?
void suspend ();// ?
};