Hi,
I describe a class parrent from QLineEdit :
#ifndef MOJEDIT_H
#define MOJEDIT_H
#include <QLineEdit>
{
//Q_OBJECT
public:
};
#endif // MOJEDIT_H
#ifndef MOJEDIT_H
#define MOJEDIT_H
#include <QLineEdit>
class MojEdit : public QLineEdit
{
//Q_OBJECT
public:
MojEdit(QWidget *parent);
virtual void mouseMoveEvent(QMouseEvent * e);
};
#endif // MOJEDIT_H
To copy to clipboard, switch view to plain text mode
& cpp
#include "mojedit.h"
#include <QMessageBox>
#include <QMouseEvent>
{
setFocusPolicy(Qt::StrongFocus);
}
{
if (e->button() == Qt::LeftButton)
{
}
else
}
#include "mojedit.h"
#include <QMessageBox>
#include <QMouseEvent>
MojEdit::MojEdit(QWidget *parent) : QLineEdit(parent)
{
setFocusPolicy(Qt::StrongFocus);
}
void MojEdit::mouseMoveEvent(QMouseEvent * e)
{
QMessageBox::about(0,"ll","BAM");
if (e->button() == Qt::LeftButton)
{
QMessageBox::about(0,"ll","BAM");
}
else
QLineEdit::mouseMoveEvent(e);
}
To copy to clipboard, switch view to plain text mode
I use it :
MojEdit *ed = new MojEdit(centralWidget);
ed
->setObjectName
(QString::fromUtf8("MojEdit"));
ed
->setGeometry
(QRect(60,
40,
113,
25));
MojEdit *ed = new MojEdit(centralWidget);
ed->setObjectName(QString::fromUtf8("MojEdit"));
ed->setGeometry(QRect(60, 40, 113, 25));
To copy to clipboard, switch view to plain text mode
And i have error :
/home/michal/jkk/mainwindow.cpp:10: error: no matching function for call to ‘MojEdit::MojEdit(<unresolved overloaded function type>)’
/home/michal/jkk/mainwindow.cpp:10: error: no matching function for call to ‘MojEdit::MojEdit(<unresolved overloaded function type>)’
To copy to clipboard, switch view to plain text mode
I add that if I have :
MojEdit *ed;
ed
->setObjectName
(QString::fromUtf8("MojEdit"));
ed
->setGeometry
(QRect(60,
40,
113,
25));
MojEdit *ed;
ed->setObjectName(QString::fromUtf8("MojEdit"));
ed->setGeometry(QRect(60, 40, 113, 25));
To copy to clipboard, switch view to plain text mode
Then it program is compiled correct , but I can't run it:
Starting /home/michal/jkk/jkk...
The program has unexpectedly finished.
/home/michal/jkk/jkk exited with code 0
Starting /home/michal/jkk/jkk...
The program has unexpectedly finished.
/home/michal/jkk/jkk exited with code 0
To copy to clipboard, switch view to plain text mode
So, what's wrong ?
/>>>> Edit <<<<
Moderator can delete this post. I resolve my problem.
I replace : centralWidget to MainWindow::centralWidget() .
Bookmarks