我有在ubuntu 11.10中内置的Qt版本.并且我试图使用一个QDockWidget实际上无法停靠的(基本上,我只是想要一个漂浮的窗口.我不想只是让视图成为顶级视图,因为那时我会将OS窗口栏放在那里,我不想要,如果我要隐藏它,那么窗口将不会移动).
所以,我基本上创建一个新的Qt Gui项目,并且不要更改任何文件,除了mainwindow.cpp我更改为的文件:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QDockWidget *dockWidget = new QDockWidget(this);
// Without window management and attached to mainwindow (central widget)
dockWidget->setFloating( true );
// resize by frame only - not positional moveable
dockWidget->setFeatures( QDockWidget::DockWidgetMovable );
// never dock in mainwindow
dockWidget->setAllowedAreas( Qt::NoDockWidgetArea );
// title
dockWidget->setWindowTitle( "Dock Widget" );
// add contents. etc etc....
dockWidget->show();
}
MainWindow::~MainWindow()
{
delete ui;
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我去移动小部件时,整个程序崩溃了.我想知道我做错了什么,或者qt中是否只有一个bug.