drag and drop => two click event, tableWidget Horizontol Size Error Fix
This commit is contained in:
parent
cdb19b9ffd
commit
1df45ea003
@ -15,11 +15,9 @@ QColor label_img::BOX_COLORS[10] ={ Qt::green,
|
|||||||
Qt::darkCyan};
|
Qt::darkCyan};
|
||||||
|
|
||||||
label_img::label_img(QWidget *parent)
|
label_img::label_img(QWidget *parent)
|
||||||
:QLabel(parent),
|
:QLabel(parent)
|
||||||
m_bMouseLeftButtonClicked(false),
|
|
||||||
m_focusedObjectLabel(0)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_img::mouseMoveEvent(QMouseEvent *ev)
|
void label_img::mouseMoveEvent(QMouseEvent *ev)
|
||||||
@ -45,18 +43,12 @@ void label_img::mousePressEvent(QMouseEvent *ev)
|
|||||||
}
|
}
|
||||||
else if(ev->button() == Qt::LeftButton)
|
else if(ev->button() == Qt::LeftButton)
|
||||||
{
|
{
|
||||||
m_bMouseLeftButtonClicked = true;
|
if(m_bLabelingStarted == false)
|
||||||
m_relatvie_mouse_pos_LBtnClicked_in_ui = m_relative_mouse_pos_in_ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit Mouse_Pressed();
|
|
||||||
}
|
|
||||||
|
|
||||||
void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
|
||||||
{
|
{
|
||||||
std::cout<< "released"<< std::endl;
|
m_relatvie_mouse_pos_LBtnClicked_in_ui = m_relative_mouse_pos_in_ui;
|
||||||
|
m_bLabelingStarted = true;
|
||||||
if(ev->button() == Qt::LeftButton && m_bMouseLeftButtonClicked == true)
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
setMousePosition(ev->x(), ev->y());
|
setMousePosition(ev->x(), ev->y());
|
||||||
|
|
||||||
@ -72,13 +64,41 @@ void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
|||||||
if(!width_is_too_small && !height_is_too_small)
|
if(!width_is_too_small && !height_is_too_small)
|
||||||
m_objBoundingBoxes.push_back(objBoundingbox);
|
m_objBoundingBoxes.push_back(objBoundingbox);
|
||||||
|
|
||||||
m_bMouseLeftButtonClicked = false;
|
m_bLabelingStarted = false;
|
||||||
}
|
|
||||||
|
|
||||||
showImage();
|
showImage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit Mouse_Pressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
||||||
|
{
|
||||||
|
std::cout<< "released"<< std::endl;
|
||||||
emit Mouse_Release();
|
emit Mouse_Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void label_img::init()
|
||||||
|
{
|
||||||
|
m_objBoundingBoxes.clear();
|
||||||
|
|
||||||
|
m_bLabelingStarted = false;
|
||||||
|
m_focusedObjectLabel = 0;
|
||||||
|
|
||||||
|
QPoint mousePosInUi = this->mapFromGlobal(QCursor::pos());
|
||||||
|
bool mouse_is_in_image = QRect(0, 0, this->width(), this->height()).contains(mousePosInUi);
|
||||||
|
|
||||||
|
if (mouse_is_in_image)
|
||||||
|
{
|
||||||
|
setMousePosition(mousePosInUi.x(), mousePosInUi.y());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setMousePosition(0., 0.);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void label_img::setMousePosition(int x, int y)
|
void label_img::setMousePosition(int x, int y)
|
||||||
{
|
{
|
||||||
if(x < 0) x = 0;
|
if(x < 0) x = 0;
|
||||||
@ -95,19 +115,7 @@ void label_img::openImage(const QString &qstrImg)
|
|||||||
m_inputImg = QImage(qstrImg);
|
m_inputImg = QImage(qstrImg);
|
||||||
m_inputImg = m_inputImg.convertToFormat(QImage::Format_RGB888);
|
m_inputImg = m_inputImg.convertToFormat(QImage::Format_RGB888);
|
||||||
|
|
||||||
m_objBoundingBoxes.clear();
|
init();
|
||||||
|
|
||||||
m_relatvie_mouse_pos_LBtnClicked_in_ui = QPointF();
|
|
||||||
|
|
||||||
m_bMouseLeftButtonClicked = false;
|
|
||||||
|
|
||||||
QPoint mousePosInUi = this->mapFromGlobal(QCursor::pos());
|
|
||||||
bool mouse_is_in_image = QRect(0, 0, this->width(), this->height()).contains(mousePosInUi);
|
|
||||||
|
|
||||||
if (mouse_is_in_image)
|
|
||||||
{
|
|
||||||
setMousePosition(mousePosInUi.x(), mousePosInUi.y());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void label_img::showImage()
|
void label_img::showImage()
|
||||||
@ -187,7 +195,7 @@ QImage label_img::crop(QRect rect)
|
|||||||
|
|
||||||
void label_img::drawCrossLine(QPainter& painter, QColor color, int thickWidth)
|
void label_img::drawCrossLine(QPainter& painter, QColor color, int thickWidth)
|
||||||
{
|
{
|
||||||
if(m_relative_mouse_pos_in_ui == QPointF()) return;
|
if(m_relative_mouse_pos_in_ui == QPointF(0., 0.)) return;
|
||||||
|
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(thickWidth);
|
pen.setWidth(thickWidth);
|
||||||
@ -207,7 +215,7 @@ void label_img::drawCrossLine(QPainter& painter, QColor color, int thickWidth)
|
|||||||
|
|
||||||
void label_img::drawFocusedObjectBox(QPainter& painter, Qt::GlobalColor color, int thickWidth)
|
void label_img::drawFocusedObjectBox(QPainter& painter, Qt::GlobalColor color, int thickWidth)
|
||||||
{
|
{
|
||||||
if(m_bMouseLeftButtonClicked)
|
if(m_bLabelingStarted == true)
|
||||||
{
|
{
|
||||||
QPen pen;
|
QPen pen;
|
||||||
pen.setWidth(thickWidth);
|
pen.setWidth(thickWidth);
|
||||||
|
@ -32,12 +32,13 @@ public:
|
|||||||
int m_imgX;
|
int m_imgX;
|
||||||
int m_imgY;
|
int m_imgY;
|
||||||
|
|
||||||
bool m_bMouseLeftButtonClicked;
|
bool m_bLabelingStarted;
|
||||||
|
|
||||||
static QColor BOX_COLORS[10];
|
static QColor BOX_COLORS[10];
|
||||||
|
|
||||||
QVector <ObjectLabelingBox> m_objBoundingBoxes;
|
QVector <ObjectLabelingBox> m_objBoundingBoxes;
|
||||||
|
|
||||||
|
void init();
|
||||||
void openImage(const QString &);
|
void openImage(const QString &);
|
||||||
void showImage();
|
void showImage();
|
||||||
|
|
||||||
|
@ -326,6 +326,7 @@ void MainWindow::keyPressEvent(QKeyEvent * event)
|
|||||||
{
|
{
|
||||||
cout << "key pressed" <<endl;
|
cout << "key pressed" <<endl;
|
||||||
int nKey = event->key();
|
int nKey = event->key();
|
||||||
|
|
||||||
bool graveAccentKeyIsPressed = (nKey == Qt::Key_QuoteLeft);
|
bool graveAccentKeyIsPressed = (nKey == Qt::Key_QuoteLeft);
|
||||||
bool numKeyIsPressed = (nKey >= Qt::Key_0 && nKey <= Qt::Key_9 );
|
bool numKeyIsPressed = (nKey >= Qt::Key_0 && nKey <= Qt::Key_9 );
|
||||||
|
|
||||||
@ -397,6 +398,7 @@ void MainWindow::init_tableWidget()
|
|||||||
{
|
{
|
||||||
ui->tableWidget_label->horizontalHeader()->setVisible(true);
|
ui->tableWidget_label->horizontalHeader()->setVisible(true);
|
||||||
ui->tableWidget_label->horizontalHeader()->setStyleSheet("");
|
ui->tableWidget_label->horizontalHeader()->setStyleSheet("");
|
||||||
|
ui->tableWidget_label->horizontalHeader()->setStretchLastSection(true);
|
||||||
|
|
||||||
disconnect(ui->tableWidget_label->horizontalHeader(), SIGNAL(sectionPressed(int)),ui->tableWidget_label, SLOT(selectColumn(int)));
|
disconnect(ui->tableWidget_label->horizontalHeader(), SIGNAL(sectionPressed(int)),ui->tableWidget_label, SLOT(selectColumn(int)));
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ border-color: rgb(0, 255, 255);</string>
|
|||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>204</width>
|
<width>210</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -671,9 +671,15 @@ QTableView {
|
|||||||
<attribute name="horizontalHeaderHighlightSections">
|
<attribute name="horizontalHeaderHighlightSections">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||||
|
<number>40</number>
|
||||||
|
</attribute>
|
||||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
<attribute name="verticalHeaderVisible">
|
<attribute name="verticalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
|
Loading…
Reference in New Issue
Block a user