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};
|
||||
|
||||
label_img::label_img(QWidget *parent)
|
||||
:QLabel(parent),
|
||||
m_bMouseLeftButtonClicked(false),
|
||||
m_focusedObjectLabel(0)
|
||||
|
||||
:QLabel(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
void label_img::mouseMoveEvent(QMouseEvent *ev)
|
||||
@ -45,18 +43,12 @@ void label_img::mousePressEvent(QMouseEvent *ev)
|
||||
}
|
||||
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;
|
||||
m_bLabelingStarted = true;
|
||||
}
|
||||
|
||||
emit Mouse_Pressed();
|
||||
}
|
||||
|
||||
void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
std::cout<< "released"<< std::endl;
|
||||
|
||||
if(ev->button() == Qt::LeftButton && m_bMouseLeftButtonClicked == true)
|
||||
else
|
||||
{
|
||||
setMousePosition(ev->x(), ev->y());
|
||||
|
||||
@ -72,13 +64,41 @@ void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
||||
if(!width_is_too_small && !height_is_too_small)
|
||||
m_objBoundingBoxes.push_back(objBoundingbox);
|
||||
|
||||
m_bMouseLeftButtonClicked = false;
|
||||
}
|
||||
m_bLabelingStarted = false;
|
||||
|
||||
showImage();
|
||||
}
|
||||
}
|
||||
|
||||
emit Mouse_Pressed();
|
||||
}
|
||||
|
||||
void label_img::mouseReleaseEvent(QMouseEvent *ev)
|
||||
{
|
||||
std::cout<< "released"<< std::endl;
|
||||
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)
|
||||
{
|
||||
if(x < 0) x = 0;
|
||||
@ -95,19 +115,7 @@ void label_img::openImage(const QString &qstrImg)
|
||||
m_inputImg = QImage(qstrImg);
|
||||
m_inputImg = m_inputImg.convertToFormat(QImage::Format_RGB888);
|
||||
|
||||
m_objBoundingBoxes.clear();
|
||||
|
||||
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());
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
void label_img::showImage()
|
||||
@ -187,7 +195,7 @@ QImage label_img::crop(QRect rect)
|
||||
|
||||
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;
|
||||
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)
|
||||
{
|
||||
if(m_bMouseLeftButtonClicked)
|
||||
if(m_bLabelingStarted == true)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setWidth(thickWidth);
|
||||
|
@ -32,12 +32,13 @@ public:
|
||||
int m_imgX;
|
||||
int m_imgY;
|
||||
|
||||
bool m_bMouseLeftButtonClicked;
|
||||
bool m_bLabelingStarted;
|
||||
|
||||
static QColor BOX_COLORS[10];
|
||||
|
||||
QVector <ObjectLabelingBox> m_objBoundingBoxes;
|
||||
|
||||
void init();
|
||||
void openImage(const QString &);
|
||||
void showImage();
|
||||
|
||||
|
@ -326,6 +326,7 @@ void MainWindow::keyPressEvent(QKeyEvent * event)
|
||||
{
|
||||
cout << "key pressed" <<endl;
|
||||
int nKey = event->key();
|
||||
|
||||
bool graveAccentKeyIsPressed = (nKey == Qt::Key_QuoteLeft);
|
||||
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()->setStyleSheet("");
|
||||
ui->tableWidget_label->horizontalHeader()->setStretchLastSection(true);
|
||||
|
||||
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 name="maximumSize">
|
||||
<size>
|
||||
<width>204</width>
|
||||
<width>210</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
@ -671,9 +671,15 @@ QTableView {
|
||||
<attribute name="horizontalHeaderHighlightSections">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||
<number>40</number>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="horizontalHeaderStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="verticalHeaderVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
|
Loading…
Reference in New Issue
Block a user