Results 1 to 8 of 8

Thread: How to find hovering on Dynamic Button

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    1

    Default Re: How to find hovering on Dynamic Button

    why dont you use css for this?....when you crate the button add:
    Qt Code:
    1. button->setStyleSheet(tr("QPushButton{}"
    2. "QPushButton:hover{}"
    3. "QPushButton:pressed{}"));
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jul 2010
    Posts
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to find hovering on Dynamic Button

    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());
    }

    }

Similar Threads

  1. Mouse hovering or press event not working?
    By qtzcute in forum Newbie
    Replies: 11
    Last Post: 15th July 2009, 10:53
  2. Custom widget: a button within a button
    By Gnurou in forum Qt Programming
    Replies: 7
    Last Post: 18th June 2009, 09:03
  3. hovering problem in QGraphicsItem
    By wagmare in forum Qt Programming
    Replies: 4
    Last Post: 13th March 2009, 17:31
  4. dynamic widgets
    By sonu111 in forum Newbie
    Replies: 1
    Last Post: 13th December 2008, 12:59
  5. QWhatsThis appear when hovering over QPushButton?
    By seanmu13 in forum Qt Programming
    Replies: 1
    Last Post: 13th June 2007, 20:06

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.