View Single Post
pichlo's Avatar
Posts: 6,453 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#6
Originally Posted by bandora View Post
I'm not going to lie to you, I'm a beginner when it comes to Qt, so please excuse my noobness
Hey, no worries, I am a learner myself!

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)..
Just use it as printf, it's as simple as that. I use it all the time when developing for the N900, mostly because I do virtually all my development on the device itself and have limited scope for other forms of debugging.

You will only see the qDebug output if you launch your program from the command line, I may have forgotten to mention tht little fact.

and when you say zoom(level * 0.5), what do you mean by that?
I mean, in your first example, you have 5 cases of mapping the parameter 'level' to some different number:
0 -> 0.25
1 -> 0.5
2 -> 1.0
3 -> 1.5
4 -> 2.0
The 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.

Here is what I meant in code. Either...

Code:
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;
	}
}
(You have some 'break' statements missing in your code, but I see you've fixed it.)

...or...

Code:
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);
	}
}
Originally Posted by bandora View Post
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..
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.

Last edited by pichlo; 2014-10-21 at 20:01. Reason: Reacted to OP's additions posted while I was typing
 

The Following 2 Users Say Thank You to pichlo For This Useful Post: