![]() |
2014-10-21
, 03:58
|
|
Posts: 1,338 |
Thanked: 1,055 times |
Joined on Oct 2009
@ California, USA / Jordan
|
#2
|
![]() |
2014-10-21
, 05:48
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#3
|
The Following User Says Thank You to pichlo For This Useful Post: | ||
![]() |
2014-10-21
, 18:49
|
|
Posts: 1,338 |
Thanked: 1,055 times |
Joined on Oct 2009
@ California, USA / Jordan
|
#4
|
void MainWindow::zoomSlider(int level) // Zoom Slider Bar Function { switch (level) { case 0: { getCurrentImageArea()->zoomImage(level * 0.50); getCurrentImageArea()->setZoomFactor(level * 0.50); } case 1: { getCurrentImageArea()->zoomImage(level * 1); getCurrentImageArea()->setZoomFactor(level * 1); } case 2: { getCurrentImageArea()->zoomImage(level* 1.50); getCurrentImageArea()->setZoomFactor(level * 1.50); } case 3: { getCurrentImageArea()->zoomImage(level* 2); getCurrentImageArea()->setZoomFactor(level * 2); } } }
![]() |
2014-10-21
, 19:08
|
|
Posts: 1,338 |
Thanked: 1,055 times |
Joined on Oct 2009
@ California, USA / Jordan
|
#5
|
void MainWindow::zoomSlider(int level) // Zoom Slider Bar Function { switch (level) { case 0: { getCurrentImageArea()->zoomImage(0.50); getCurrentImageArea()->setZoomFactor(0.50); break; } case 1: { getCurrentImageArea()->zoomImage(1); getCurrentImageArea()->setZoomFactor(1); break; } case 2: { getCurrentImageArea()->zoomImage(2); getCurrentImageArea()->setZoomFactor(2); break; } case 3: { getCurrentImageArea()->zoomImage(4); getCurrentImageArea()->setZoomFactor(4); break; } } }
![]() |
2014-10-21
, 19:56
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#6
|
I'm not going to lie to you, I'm a beginner when it comes to Qt, so please excuse my noobness
I tried using the qDebug but I am not even sure if I'm doing that correctly either (even when I read about it a bit online)..
and when you say zoom(level * 0.5), what do you mean by that?
0 -> 0.25The first thing that stands out is that with the exception of the first case, the mapped number is always 0.5 times the value of the parameter 'level'. In other words, level*0.5.
1 -> 0.5
2 -> 1.0
3 -> 1.5
4 -> 2.0
void MainWindow::zoomSlider(int level) // Zoom Slider Bar Function { qDebug("zoomSlider() called, level==%d", level); switch (level) { case 0: getCurrentImageArea()->zoomImage(0.25); getCurrentImageArea()->setZoomFactor(0.25); break; case 1: getCurrentImageArea()->zoomImage(0.5); getCurrentImageArea()->setZoomFactor(0.5); break; case 2: getCurrentImageArea()->zoomImage(1.0); getCurrentImageArea()->setZoomFactor(1.0); break; case 3: getCurrentImageArea()->zoomImage(1.5); getCurrentImageArea()->setZoomFactor(1.5); break; case 4: getCurrentImageArea()->zoomImage(2.0); getCurrentImageArea()->setZoomFactor(2.0); break; } }
void MainWindow::zoomSlider(int level) // Zoom Slider Bar Function { qDebug("zoomSlider() called, level==%d", level); if (level == 0) { getCurrentImageArea()->zoomImage(0.25); getCurrentImageArea()->setZoomFactor(0.25); } else { getCurrentImageArea()->zoomImage(level * 0.5); getCurrentImageArea()->setZoomFactor(level * 0.5); } }
Basically, it doesn't have set zoom to it.. Hard to explain it but, like if you go to the min value it's not like it's set to make it only 50% for example, but it does zoom out, but it's setting it to a specific value..
The Following 2 Users Say Thank You to pichlo For This Useful Post: | ||
![]() |
2014-10-21
, 20:25
|
|
Posts: 1,338 |
Thanked: 1,055 times |
Joined on Oct 2009
@ California, USA / Jordan
|
#7
|
SNIP..
I'm afraid you've lost me there. But now your zoomSlider method is more or less correct, have a look at the rest of your code.
![]() |
2014-10-21
, 20:56
|
|
Posts: 6,450 |
Thanked: 20,983 times |
Joined on Sep 2012
@ UK
|
#8
|
The Following User Says Thank You to pichlo For This Useful Post: | ||
![]() |
2014-10-21
, 21:26
|
|
Posts: 1,338 |
Thanked: 1,055 times |
Joined on Oct 2009
@ California, USA / Jordan
|
#9
|
Sorry, I am a bit short on time but even if I were not, I am not going to run a random exe. No offence intended, just a personal policy.
However, to expand on this...
...I would have a look at what's behind your getCurrentImageArea(), zoomImage() and setZoomFactor() and why are both zoomImage() and setZoomFactor() called each time. Maybe only one needs to be called?
Here is an excellent example of a simple image zooming code, straight from the creators of Qt:
http://qt-project.org/doc/qt-4.8/wid...ageviewer.html
It might be a good idea to have a read through that article. It is quite long and a bit fragmented (it never shows the whole code), so to fully comprehend it you may need to read it front to end. It may not fit your specifications exactly but it may give you some inspiration.
![]() |
2014-10-21
, 22:54
|
|
Posts: 2,448 |
Thanked: 9,523 times |
Joined on Aug 2010
@ Wigan, UK
|
#10
|
void MainWindow::zoomSlider(int level) { const qreal zoomFactor = level > oldLevel ? 2.0 : 0.5; qreal zoom = 1.0; for (int i = 0; i < qAbs(level - oldLevel); i++) { zoom *= zoomFactor; } getCurrentImageArea()->zoomImage(zoom); getCurrentImageArea()->setZoomFactor(zoom); oldLevel = level; }
I am modifying EasyPaint to practice on different aspects of Qt, and I am trying to add a zoom slider function onto the status bar, I got it to work but there is a bug that I can't figure out.. Basically, the zoom doesn't work properly.. If someone can help me with this problem I will definitely appreciate it! <3
This is the code that I've added to mainwindow.h (in 'private slots'):
FarahFa.com