-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidget.cpp
More file actions
90 lines (69 loc) · 2.48 KB
/
widget.cpp
File metadata and controls
90 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "widget.h"
#include "ui_widget.h"
#include <QHBoxLayout>
#include <QQmlComponent>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickView>
#include <QDockWidget>
#include <QQuickStyle>
ChatWidget::ChatWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
QBoxLayout *box = new QBoxLayout(QBoxLayout::BottomToTop, this);
box->setSpacing(0);
box->setMargin(0);
//QQuickStyle::setStyle("Fusion");
QQuickView * view = new QQuickView();
//view->setColor(QColor("#000000"));
//view->setOpacity(0.2);
view->setResizeMode(QQuickView::SizeRootObjectToView);
//view->setWidth(this->width());
//view->setHeight(this->height());
//view->show();
m_context = view->engine()->rootContext();
//m_context->setContextProperty(QStringLiteral("something"), &something)
m_context->setContextProperty("globalUserName", "ValentynFk");
m_context->setContextProperty("globalTheme", "white");
view->setSource(QUrl("qrc:/chat.qml"));
//QQmlContext * context = view->engine()->rootContext();
//context->setContextProperty("mode", "disabled");
//context->setContextProperty("width", this->width());
//context->setContextProperty("height", this->height());
//int width = context->contextProperty("width").toInt();
//int height = context->contextProperty("height").toInt();
//view->setIcon(QIcon(":/img/CONNECTED.png"));
//view->setTitle(QString("chat"));
//view->setWidth(this->width());
//view->setHeight(this->height());
//view->setPosition(this->x(), this->y());
//qDebug() << "width is: " << context->contextProperty("width");
QWidget *container = QWidget::createWindowContainer(view, this);
container->setContextMenuPolicy(Qt::NoContextMenu);
container->setContentsMargins(0, 0, 0, 0);
container->update();
//container->hide();
//container->setMinimumSize(200, 200);
//container->setMaximumSize(200, 200);
container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
container->setFocusPolicy(Qt::StrongFocus);
//setWindowIcon(QIcon(":/chatelements/res/CONNECTED.png"));
setWindowTitle(QString("QML chat"));
setEnabled(false);
setMinimumSize(200, 200);
setMaximumSize(800, 800);
setGeometry(100, 100, 800, 800);
box->addWidget(container);
setLayout(box);
}
void ChatWidget::resizeEvent(QResizeEvent *)
{
qDebug() << "in resize event";
update();
repaint();
}
ChatWidget::~ChatWidget()
{
delete ui;
}