tags:

views:

157

answers:

1

I'm not big on creating GUI's, and generally my philosophy is: I don't create them, or I make them as simple as possible (and convince myself that it's better for usability :)

For my current project, I'm using Qt from Python (PyQt), and I want to start adding some GUI elements without cluttering the interface.

My idea is to create these elements as sort of floating-shaped-widgets that only appear when necessary; pretty much like the status bar (and find bar) in chrome.

Is there any standard api that enables creating this kind of interface?

+3  A: 

Hello,

This is not very complicated. If you want something like the status bar in Chrome you just need to have a QFrame at the bottom of your windows and show or hide it when you need it.

You have 2 options here, add is as part of your window layout so all the items move up when it is shown. Or you can have if floating, so it will be shown on top of the items. For the second option you need to create the QFrame with the window as parent and then in the window resizeEvent set the geometry of the frame.

This is an example of the second approach:

void MyWindow::resizeEvent(QResizeEvent* event) { frame.setGeometry(0, this->height() - frame.sizeHint().height(), this->width(), frame.sizeHint().height()); }

I hope this helps.

cnebrera
yea it does, thanks! I'll try it
hasen j
You are welcome :). If you want to do it even cooler you can add animation, so the bar grow up when it is going to appear. You can use a QTimeLine for that connected to an slot that made the bar grow on show event. (I think there are also special Qt classes for animations but I have never try them)
cnebrera