Results 1 to 7 of 7

Thread: Display Popup Frame with contents on mouse hover in main window

  1. #1
    Join Date
    Jan 2013
    Posts
    25
    Thanks
    2
    Platforms
    Windows

    Question Display Popup Frame with contents on mouse hover in main window

    I need to display image(s) in a popup frame at a position when mouse hovers at that position in my main window.

    My idea is to create QPixmaps from image file---->put them in QListView using MVC ---->add the listview to QFrame. Is it correct strategy?

    How can I make sure that popup frame is displayed at the position where mouse is hovering?


    Regards,
    Tariq

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Display Popup Frame with contents on mouse hover in main window

    If have a specific widget at the position on the mainwindow, then it will quick and simple to set a tool tip on that widget. Add img html tags in the tool tip string.

    Here is an example, assuming you have images in resource files.
    Qt Code:
    1. QWidget * widget;//widget in mainwindow
    2.  
    3. QString html = "<p><img src=\":images/image-1.ico\" height=\"50\" width=\"50\"></p>"
    4. "<p><img src=\":images/image-2.ico\" height=\"50\" width=\"50\"></p>"
    5. "<p><img src=\":images/image-3.ico\" height=\"50\" width=\"50\"></p>"
    6. "<p><img src=\":images/image-4.ico\" height=\"50\" width=\"50\"></p>";
    7.  
    8. widget.setToolTip(html);
    To copy to clipboard, switch view to plain text mode 

    Note this approach will not be of much use if you plan to select the images in the popoup. If you need to select the images in the popup then QMenu or QListView approach is better
    Last edited by Santosh Reddy; 12th August 2013 at 12:13.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2013
    Posts
    25
    Thanks
    2
    Platforms
    Windows

    Default Re: Display Popup Frame with contents on mouse hover in main window

    Santosh, thanks for reply.

    I am having a progress bar like representation of multimedia files in a QFrame.
    I need to display 5 thumbnails from that file in a popup frame/QListView/anything (I am not sure what will it be), when mouse hovers over a file representation.

    Can you suggest an idea to solve this problem?

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Display Popup Frame with contents on mouse hover in main window

    I am having a progress bar like representation of multimedia files in a QFrame.
    I need to display 5 thumbnails from that file in a popup frame/QListView/anything (I am not sure what will it be), when mouse hovers over a file representation.
    Do you want mouse interactions with image thumbnails (like click, hover etc)? or are thumbnails are just static display? and will disappear when the mouse is moved away from the progressbar.

    Can you suggest an idea to solve this problem?
    Will the above suggested method not work for you? Why?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Jan 2013
    Posts
    25
    Thanks
    2
    Platforms
    Windows

    Default Re: Display Popup Frame with contents on mouse hover in main window

    Thumbnails are just static display and will disappear when mouse is moved away from that position. New thumbnails will be loaded for new position on mouse hover at the new position

    Below is how my progress bar will look like. black stripes represent files at that location. (Small white frame at top-left is my popup frame for images. It is not working)
    Attachment 9405

    I am stuck and finding no way to move further.

  6. #6
    Join Date
    Jan 2013
    Posts
    25
    Thanks
    2
    Platforms
    Windows

    Default Re: Display Popup Frame with contents on mouse hover in main window

    Quote Originally Posted by Santosh Reddy View Post
    Do you want mouse interactions with image thumbnails (like click, hover etc)? or are thumbnails are just static display? and will disappear when the mouse is moved away from the progressbar.


    Will the above suggested method not work for you? Why?
    Thanks Santosh.
    Two small, related question, after seeing your suggestion working.
    1. How can I rotate tooltip contents to horizontal orientation from vertical?
    2. Secondly, my thumbnails are going beyond screen display. How can I add scroll bars to it?
    Last edited by tesmai4; 12th August 2013 at 17:54.

  7. #7
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Display Popup Frame with contents on mouse hover in main window

    How can I rotate tooltip contents to horizontal orientation from vertical?
    remove the <p>..</p> tags from the html string.

    Secondly, my thumbnails are going beyond screen display. How can I add scroll bars to it?
    You cannot add scroll bars to ToolTips. If you need to restrict the popup and add scroll bars then you have go with QListWidget / QWidget / QFrame approach.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

Similar Threads

  1. Replies: 26
    Last Post: 7th January 2016, 21:26
  2. Replies: 0
    Last Post: 8th June 2012, 14:27
  3. Replies: 2
    Last Post: 17th February 2011, 13:30
  4. Add a Frame Widget to the main window
    By kamlmish in forum Qt Programming
    Replies: 2
    Last Post: 30th November 2010, 09:51
  5. Main Window frame height
    By ^NyAw^ in forum Qt Programming
    Replies: 18
    Last Post: 13th November 2007, 13:14

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.