void Photogallery::createbuttons() //function called from constructor to create the
//8 pushbuttons
{
<<<<code to create the 8 buttons>>>
QDir CurrentDirectory
("/root/Desktop/photos");
//'photos' dir. contains pictures names
= CurrentDirectory.
entryList(QDir::Files|QDir
::NoDotAndDotDot);
//'names' is a Qstringlist variable
connect(timer,SIGNAL(timeout()),this,SLOT(update()));
timer->start();
}
void Mediagallery::update() //slot which sets up the images on buttons
{
it= names.begin(); //'it' is QStringlist iterator
int count=(names.size()/8);
for(int numimage=0;numimage<count;numimage++)
{
//first picture on first button.
firstImagepath = "/root/Desktop/photos/"+Imagename;
QPixmap imagedisplay
(firstImagepath
);
QIcon icon
(imagedisplay
);
firstImage->setIcon(icon); //firstImage is a Qpushbutton
connect(firstImage,SIGNAL(pressed()),this,SLOT(buttondown()));
//buttondown() is a slot where I identify which button is clicked.
//***********************************************************
//second picture on second button
it5++;
secondImagepath = "/root/Desktop/photos/"+Imagename2;
QPixmap imagedisplay2
(secondImagepath
);
secondImage->setIcon(imagedisplay2);
connect(secondImage,SIGNAL(pressed()),this,SLOT(buttondown()));
//*************************************************************
//third picture on third pushbutton
it5++;
thirdImagepath= "/root/Desktop/photos/"+Imagename3;
QPixmap imagedisplay3
(thirdImagepath
);
thirdImage->setIcon(imagedisplay3);
connect(thirdImage,SIGNAL(pressed()),this,SLOT(buttondown()));
.........so on till 8th image is set.
QMessageBox::information(NULL,
"",numimagestr
);
//keeping count }
}
void Photogallery::createbuttons() //function called from constructor to create the
//8 pushbuttons
{
<<<<code to create the 8 buttons>>>
QDir CurrentDirectory("/root/Desktop/photos"); //'photos' dir. contains pictures
names= CurrentDirectory.entryList(QDir::Files|QDir::NoDotAndDotDot);
//'names' is a Qstringlist variable
timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(update()));
timer->start();
}
void Mediagallery::update() //slot which sets up the images on buttons
{
it= names.begin(); //'it' is QStringlist iterator
int count=(names.size()/8);
for(int numimage=0;numimage<count;numimage++)
{
//first picture on first button.
QString Imagename(*it5);
firstImagepath = "/root/Desktop/photos/"+Imagename;
QPixmap imagedisplay(firstImagepath);
QIcon icon(imagedisplay);
firstImage->setIcon(icon); //firstImage is a Qpushbutton
connect(firstImage,SIGNAL(pressed()),this,SLOT(buttondown()));
//buttondown() is a slot where I identify which button is clicked.
//***********************************************************
//second picture on second button
it5++;
QString Imagename2(*it5);
secondImagepath = "/root/Desktop/photos/"+Imagename2;
QPixmap imagedisplay2(secondImagepath);
secondImage->setIcon(imagedisplay2);
connect(secondImage,SIGNAL(pressed()),this,SLOT(buttondown()));
//*************************************************************
//third picture on third pushbutton
it5++;
QString Imagename3(*it5);
thirdImagepath= "/root/Desktop/photos/"+Imagename3;
QPixmap imagedisplay3(thirdImagepath);
thirdImage->setIcon(imagedisplay3);
connect(thirdImage,SIGNAL(pressed()),this,SLOT(buttondown()));
.........so on till 8th image is set.
QString numimagestr=QString::number(numimage);
QMessageBox::information(NULL,"",numimagestr); //keeping count
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks