3

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?

hasen
  • 161,647
  • 65
  • 194
  • 231
  • Take a look at the rekonq browser (http://rekonq.sourceforge.net/). It has the same kind of status bar as chrome and is written using Qt. – mtvec Jun 03 '10 at 10:08
  • That seems like just a hack, which I could do anyway .. what I'm asking for is some sort of a solid api (if any!!) – hasen Jun 04 '10 at 04:40

1 Answers1

5

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
  • 695
  • 3
  • 5
  • 1
    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 Jun 11 '10 at 21:00
  • What if we would like to support standard status tips (from toolbar buttons, menus, etc.) in this floating status bar? – Flavio Tordini Mar 27 '15 at 17:25