View Single Post
bandora's Avatar
Posts: 1,338 | Thanked: 1,055 times | Joined on Oct 2009 @ California, USA / Jordan
#1
Hello,

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'):

Code:
void zoomSlider(int level);
And this is what I've added to mainwindow.cpp (in "void MainWindow::initializeStatusBar()")

Code:
	QSlider *zoomSliderBar = new QSlider(Qt::Horizontal, this);
	
	zoomSliderBar->setTickPosition(QSlider::TicksBothSides);
	// Slider not inverted
	zoomSliderBar->setInvertedAppearance(false);
	// Min value to max value
	zoomSliderBar->setRange(0,4);
	// Initial Value of Slider Bar
	zoomSliderBar->setValue(2);
	// Add the widget at the bottom (status bar)
	mStatusBar->addPermanentWidget(zoomSliderBar, 1);

	connect(zoomSliderBar,SIGNAL(valueChanged(int)), this, SLOT(zoomSlider(int)));
And finally I also added this to the mainwindow.cpp (on top of the "initializeStatusBar()" function)

Code:
void MainWindow::zoomSlider(int level) // Zoom Slider Bar Function
{
	if (level == 0)
	{
		getCurrentImageArea()->zoomImage(0.25);
		getCurrentImageArea()->setZoomFactor(0.25);
	}

	else if (level == 1)
	{
		getCurrentImageArea()->zoomImage(0.50);
		getCurrentImageArea()->setZoomFactor(0.50);
	}

	else if (level == 2)
	{
		getCurrentImageArea()->zoomImage(1);
		getCurrentImageArea()->setZoomFactor(1);
	}

	else if (level == 3)
	{
		getCurrentImageArea()->zoomImage(1.50);
		getCurrentImageArea()->setZoomFactor(1.50);
	}

	else if (level == 4)
	{
		getCurrentImageArea()->zoomImage(2);
		getCurrentImageArea()->setZoomFactor(2);
	}
}
I personally think maybe my "void MainWindow::zoomSlider(int level)" is not working properly, but I don't know how to fix it..
__________________
FarahFa.com