我注意到QML的StatusBar类型不包含像QStatusBar一样的SizeGrip。带SizeGrip的QML状态栏
为了获得大小的控制权,我不得不将QML嵌入QMainWindow和QStatusBar中。虽然这有效,但它使应用程序的其他部分变得复杂,并且这不是我所追求的设计。
是否有可能通过继承QML直接在QML中实现QStatusBar,以及QML如何识别/使用SizeGrip?
编辑: 我已经尝试获得QQuickPaintedItem尝试和QML呈现QStatusBar,但到目前为止还没有任何运气。在渲染调用中触发错误:QCoreApplication :: sendEvent中的ASSERT失败:“无法将事件发送给其他线程拥有的对象当前线程399d3d8。接收器'(类型'QStatusBar')在线程8c9f00” ,文件内核\ qcoreapplication.cpp,553
.H
class WindowStatusBar : public QQuickPaintedItem
{
Q_OBJECT
public:
explicit WindowStatusBar(QQuickItem *parent = 0);
virtual ~WindowStatusBar();
void paint(QPainter *painter);
protected:
QStatusBar *statusBar_;
};
的.cpp
WindowStatusBar::WindowStatusBar(QQuickItem *parent)
: QQuickPaintedItem(parent)
, statusBar_(NULL)
{
setOpaquePainting(true);
setAcceptHoverEvents(true);
setAcceptedMouseButtons(Qt::AllButtons);
statusBar_ = new QStatusBar;
}
WindowStatusBar::~WindowStatusBar()
{
delete statusBar_;
}
void WindowStatusBar::paint(QPainter *painter)
{
statusBar_->render(painter, QPoint(), QRegion(),
QStatusBar::DrawWindowBackground | QStatusBar::DrawChildren);
}
我已经更新了这个问题,我现在正在尝试创建一个QML QStatusBar。这主要是我关注的路径,因为我发现在窗口中使用MouseArea而不是QSizeGrip来调整窗口的大小并不那么光滑。 –