MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / T_Card

Method T_Card

ElaWidgetToolsExample/ExamplePage/T_Card.cpp:8–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include "ElaInteractiveCard.h"
7#include "ElaLCDNumber.h"
8#include "ElaPromotionCard.h"
9#include "ElaPromotionView.h"
10#include "ElaText.h"
11
12#include <QVBoxLayout>
13
14T_Card::T_Card(QWidget* parent)
15 : T_BasePage(parent)
16{
17 setWindowTitle("卡片展示");
18 createCustomWidget("组合图片、标题和操作入口,体验卡片悬停、轮播与数字显示。", "卡片与内容展示");
19 auto* mainLayout = createPageLayout();
20 auto* promotionSection = addExampleSection(mainLayout, "推广卡片 · ElaPromotionCard", "移动指针或点击卡片,观察图片上的光效。");
21 _promotionCard = new ElaPromotionCard(this);
22 _promotionCard->setMinimumWidth(0);
23 _promotionCard->setFixedHeight(260);
24 _promotionCard->setCardPixmap(QPixmap(":/Resource/Image/Card/miku.png"));
25 _promotionCard->setCardTitle("Ela 组件展示");
26 _promotionCard->setPromotionTitle("精选内容");
27 _promotionCard->setTitle("发现更好的界面");
28 _promotionCard->setSubTitle("图片与文字组成内容入口");
29 promotionSection->addWidget(_promotionCard);
30
31 auto* linkSection = addExampleSection(mainLayout, "链接与交互卡片", "ElaAcrylicUrlCard 用于链接入口,ElaInteractiveCard 用于可点击的内容项。");
32 auto* linkLayout = new ElaFlowLayout(0, 24, 16);
33 auto* repositoryCard = new ElaAcrylicUrlCard(this);
34 repositoryCard->setFixedSize(210, 210);
35 repositoryCard->setCardPixmap(QPixmap(":/Resource/Image/github.png"));
36 repositoryCard->setTitle("项目源码");
37 repositoryCard->setSubTitle("浏览 ElaWidgetTools 的组件与示例");
38 repositoryCard->setUrl("https://github.com/Liniyous/ElaWidgetTools");
39 auto* projectCard = new ElaInteractiveCard(this);
40 projectCard->setFixedSize(300, 100);
41 projectCard->setCardPixmap(QPixmap(":/Resource/Image/Cirno.jpg"));
42 projectCard->setTitle("示例项目");
43 projectCard->setSubTitle("点击选择此项目");
44 auto* cardResultText = new ElaText("尚未选择项目", this);
45 connect(projectCard, &ElaInteractiveCard::clicked, this, [cardResultText]() {
46 cardResultText->setText("已选择:示例项目");
47 });
48 linkLayout->addWidget(repositoryCard);
49 linkLayout->addWidget(createLabeledControl("内容入口", projectCard));
50 linkSection->addLayout(linkLayout);
51 linkSection->addWidget(cardResultText);
52
53 auto* carouselSection = addExampleSection(mainLayout, "卡片轮播 · ElaPromotionView", "点击两侧卡片或滚动鼠标滚轮切换,也可以启用自动轮播。");
54 _promotionView = new ElaPromotionView(this);
55 _promotionView->setFixedHeight(260);
56 const QStringList images{"miku", "beach", "dream", "classroom"};
57 const QStringList titles{"灵感画廊", "海边时光", "梦境色彩", "学习空间"};
58 for (int index = 0; index < images.count(); ++index)
59 {
60 auto* card = new ElaPromotionCard(this);
61 card->setCardPixmap(QPixmap(QString(":/Resource/Image/Card/%1.png").arg(images[index])));
62 card->setCardTitle(QString("精选 %1").arg(index + 1));
63 card->setTitle(titles[index]);
64 card->setSubTitle("点击切换当前卡片");
65 card->setTitlePixelSize(22);

Callers

nothing calls this directly

Calls 7

setIsUseAutoClockMethod · 0.80
setFixedHeightMethod · 0.80
setFixedSizeMethod · 0.80
appendPromotionCardMethod · 0.80
setIsAutoScrollMethod · 0.80
addWidgetMethod · 0.80
setIsTransparentMethod · 0.45

Tested by

no test coverage detected