QLabel snap to ScrollBar
-
@Mikeeeeee Do you actually read documentation?
https://doc.qt.io/qt-5/qwidget.html#move-1 -
@Mikeeeeee
Hi
Its not a signal but a virtual function.
You have to override it.Right clik on the class name

Then select

and you get the functionprotected: virtual void wheelEvent(QWheelEvent *event) override { }Then do same right click again and select

to move the body of function to the cpp file.
Now you can try to implement your zoom.
@mrjj said in QLabel snap to ScrollBar:
Right clik on the class name
OMG, this is an option in QtC ?
I feel so stupid now....
-
Do so. But tied to a Qlabel , and not to the Image. Is it possible to link to an Image?
QImage mapImage(":/Images/Images/mapMain.png"); ImageViewer* myImageViewer = new ImageViewer(); myImageViewer->setImage(mapImage); ui->verticalLayout->addWidget(myImageViewer); QPushButton* btn1 = new QPushButton(myImageViewer); btn1->setFixedSize(20,20); btn1->setText("*"); btn1->move(20,20); -
Do so. But tied to a Qlabel , and not to the Image. Is it possible to link to an Image?
QImage mapImage(":/Images/Images/mapMain.png"); ImageViewer* myImageViewer = new ImageViewer(); myImageViewer->setImage(mapImage); ui->verticalLayout->addWidget(myImageViewer); QPushButton* btn1 = new QPushButton(myImageViewer); btn1->setFixedSize(20,20); btn1->setText("*"); btn1->move(20,20);@Mikeeeeee said in QLabel snap to ScrollBar:
QPushButton* btn1 = new QPushButton(myImageViewer);
btn1->setFixedSize(20,20);
btn1->setText("*");
btn1->move(20,20);You forgot
btn1->show(); -
@Mikeeeeee said in QLabel snap to ScrollBar:
How do I know the visible coordinates of an Image?
What do you mean?
What are "visible coordinates" and relative to what do you want to have them?
Do you mean you want to know which part of displayed image is visible? -
Partially solve. But regardless of the scrollbar state, pageStep() returns a single value
qDebug()<<scrollArea->horizontalScrollBar()->value() <<scrollArea->horizontalScrollBar()->maximum() <<scrollArea->horizontalScrollBar()->minimum() <<scrollArea->horizontalScrollBar()->pageStep(); -
@Mikeeeeee said in QLabel snap to ScrollBar:
pageStep
But it is a single step value. how much to scroll for a page.
What do you need it for ? -
Hi
If i do
// createActions();
it starts fine.
Please provide more details. -
hi
I think its something else than createActions();
Use the debugger to find the line where it crashes. -
error in qaction.cpp
void QAction::setEnabled(bool b) { Q_D(QAction); if (b == d->enabled && b != d->forceDisabled) return; d->forceDisabled = !b; if (b && (!d->visible || (d->group && !d->group->isEnabled()))) return; QAPP_CHECK("setEnabled"); d->enabled = b; #ifndef QT_NO_SHORTCUT d->setShortcutEnabled(b, qApp->d_func()->shortcutMap); //here #endif d->sendDataChanged(); }