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?

4

1 回答 1

5

这不是很复杂。如果你想要 Chrome 中的状态栏之类的东西,你只需要在窗口底部有一个 QFrame 并在需要时显示或隐藏它。

您在这里有 2 个选项,添加是作为窗口布局的一部分,因此所有项目在显示时都会向上移动。或者你可以让 if 浮动,所以它会显示在项目的顶部。对于第二个选项,您需要创建以窗口为父窗口的 QFrame,然后在窗口 resizeEvent 中设置框架的几何形状。

这是第二种方法的示例:

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

我希望这有帮助。

于 2010-06-11T08:59:46.150 回答