Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
4.4.0
-
None
Description
At present, Qt 4.4.0 does not support floating QToolBars which have a title bar.
This functionality is quite common and for instance can be found in Microsoft Office, Visual Studio, OpenOffice and Perforce GUI applications.
Here is an example which comes very close to replicating this behavior; however it is not quite right:
#include <QtGui>
class ToolBar : public QToolBar
{
Q_OBJECT
public:
ToolBar(const QString &title, QWidget *parent = 0)
: QToolBar(title, parent), recursion(false)
{
}
void showEvent(QShowEvent *event)
{
if(isFloating()){
if(recursion)
else
{ recursion = true; hide(); setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint); setFixedSize(sizeHint()); show(); }} else
{ setMaximumSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX); setMinimumSize(0, 0); } QToolBar::showEvent(event);
}
private:
bool recursion;
};
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0)
: QMainWindow(parent)
};
#include "main.moc"
int main(int argc, char **argv)
{
QApplication a(argc, argv);
MainWindow mw;
mw.show();
return a.exec();
}
This example shows that the behavior is definitely possible.
There should at least be an option to enable/disable title bars on floating QToolBars rather than assume that the user does not want/need them.
Attachments
Issue Links
- relates to
-
QTBUG-797 Toolbars don't have a small X in the corner
-
- Closed
-