-
Notifications
You must be signed in to change notification settings - Fork 1
/
userchildwidget.cpp
63 lines (58 loc) · 1.6 KB
/
userchildwidget.cpp
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
#include "userchildwidget.h"
#include "ui_userchildwidget.h"
UserChildWidget::UserChildWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::UserChildWidget)
{
ui->setupUi(this);
self_info = new S_FRIEND_INFO;
ui->lb_feeling->setAlignment(Qt::AlignHCenter);
}
UserChildWidget::~UserChildWidget()
{
delete ui;
}
#include <QBitmap>
void UserChildWidget::set_info(S_FRIEND_INFO* friend_info)
{
strcpy_s(self_info->feeling, sizeof(friend_info->feeling), friend_info->feeling);
strcpy_s(self_info->name,sizeof(friend_info->name), friend_info->name);
self_info->icon = friend_info->icon;
self_info->state = friend_info->state;
self_info->type = friend_info->type;
self_info->userid = friend_info->userid;
//ui更新
QString name(self_info->name);
ui->lb_name->setText(name);
QString feeling(self_info->feeling);
ui->lb_feeling->setText(feeling);
// 对资源的引用 :/
QString path = QString(":/tx/%1.png").arg(self_info->icon);
//在线彩色
if(self_info->state || self_info->userid == 2)
ui->pb_icon->setIcon(QIcon(path));
else{
QBitmap bmp;
bmp.load(path);
ui->pb_icon->setIcon(bmp);
}
//重绘
this->repaint();
}
void UserChildWidget::set_offline()
{
QString path = QString(":/tx/%1.png").arg(self_info->icon);
QBitmap bmp;
bmp.load(path);
ui->pb_icon->setIcon(bmp);
this->repaint();
}
void UserChildWidget::mouseDoubleClickEvent()
{
Q_EMIT icon_clicked(self_info->userid);
}
//头像槽
void UserChildWidget::on_pb_icon_clicked()
{
Q_EMIT icon_clicked(self_info->userid);
}