Unsolved I want to highlight the grid layout view port after click?
-
I have a grid layout and inside i distribute the layout in four section. So, I want to highlight the port by clicking on the viewport.
This is my grid layout image view :Once I clicked on viewport it will be highlighted.
-
Hi,
What are these sections ?
-
@SGaist suppose this one is a widget. I want to highlight the widget after clicking
-
What about QRubberBand ?
-
@SGaist This one not working for me
-
Well... With that much information, it sure is easy to help you.
You might want to consider explaining what you tried, what you got, etc.
-
@SGaist I used this one code for highlighting. I do not understand, why we r taking "origin". In this link http://doc.qt.io/qt-5/qrubberband.html
void mainwindow::mousePressEvent(QMouseEvent *event)
{
//origin = event->pos();
if (!this->ui->view1)
return;
this->ui->view1->setGeometry(QRect(event->pos(), QSize()));
this->ui->view1->show();
}void mainwindow::mouseMoveEvent(QMouseEvent *event)
{
this->ui->view1->setGeometry(QRect(event->pos(), event->pos()).normalized());
}void mainwindow::mouseReleaseEvent(QMouseEvent *event)
{
this->ui->view1->hide();
} -
@SGaist
Can I create a border around it? So, it will show highlighted after clicking. -
In your case, you don't build the rectangle using mouse move, hence you can ignore that part. A border around what ?
-
@SGaist Border around the widget after mouse clicking?
After removing the mouse move code my output comes like this and when i will press after the widget 1. it will change to normal form.