why dont you use css for this?....when you crate the button add:
Qt Code:
button->setStyleSheet(tr("QPushButton{}" "QPushButton:hover{}" "QPushButton:pressed{}"));To copy to clipboard, switch view to plain text mode
why dont you use css for this?....when you crate the button add:
Qt Code:
button->setStyleSheet(tr("QPushButton{}" "QPushButton:hover{}" "QPushButton:pressed{}"));To copy to clipboard, switch view to plain text mode
The project was stopped but now ctnd. . Thanks for the sugesstions, I got it by creating n event class. Now , I am trying to read a folder and show image on the button as animation. When the mouse runs on the button, it will read the pics from the folder and show one by one, but i am not able to do that in while or by timer..
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
event_class::event_class(QWidget *parent) :
QPushButton(parent)
{
p_b=0;
}
void event_class::enterEvent(QEvent *e)
{
QDir directory(file_path);
QStringList file_names = directory.entryList(QDir::Files,QDir::Name);
pos=p_b->geometry();
int count = 0;
while(count<file_names.count())
{
QPixmap* pixmap = new QPixmap();
pixmap->load(directory.absoluteFilePath(file_names[count]));
QIcon icon(*pixmap);
QSize iconSize(pixmap->width(), pixmap->height());
this->setIconSize(iconSize);
this->setIcon(icon);
sleep(50);
count = (count+1)%(file_names.count());
}
}
Bookmarks