PDA

View Full Version : Display Popup Frame with contents on mouse hover in main window



tesmai4
12th August 2013, 09:50
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

Santosh Reddy
12th August 2013, 11:07
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.


QWidget * widget;//widget in mainwindow

QString html = "<p><img src=\":images/image-1.ico\" height=\"50\" width=\"50\"></p>"
"<p><img src=\":images/image-2.ico\" height=\"50\" width=\"50\"></p>"
"<p><img src=\":images/image-3.ico\" height=\"50\" width=\"50\"></p>"
"<p><img src=\":images/image-4.ico\" height=\"50\" width=\"50\"></p>";

widget.setToolTip(html);

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

tesmai4
12th August 2013, 11:39
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?

Santosh Reddy
12th August 2013, 12:13
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?

tesmai4
12th August 2013, 13:18
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)
9405

I am stuck and finding no way to move further.

tesmai4
12th August 2013, 15:36
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.

How can I rotate tooltip contents to horizontal orientation from vertical?
Secondly, my thumbnails are going beyond screen display. How can I add scroll bars to it?

Santosh Reddy
12th August 2013, 18:13
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.