QT -狗狗管理工具


一、演示效果

请添加图片描述

请添加图片描述

二、UML

请添加图片描述

三、关键代码

#include <QFrame>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QSizePolicy>
#include <QDialog>
#include <QDialogButtonBox>


#include "DogVisitorCard.h"
#include "DogVisitorInfoPanel.h"
#include "Dog/owner.h"
#include "./view/buttons/ButtonsWidget.h"

#include "breeds/breed.h"
#include "breeds/amstaff.h"
#include "breeds/bulldog.h"



QVBoxLayout* DogVisitorCard::getCard() const{
   
    return cardLayout;
}

void DogVisitorCard::visitBoarding(Boarding &boarding) {
   

    QHBoxLayout* hbox=new QHBoxLayout();

    dog=&boarding;

    hbox->addSpacing(30);

    //left image
    QHBoxLayout* img= new QHBoxLayout();
    QLabel* image= new QLabel();
    image->setPixmap(QPixmap(":/assets/icons8-dog-house-64.png"));
    image->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    img->addWidget(image);
    hbox->addLayout(img);


    hbox->addSpacing(25);


    //Dog's info
    QVBoxLayout* info= new QVBoxLayout();
    hbox->addLayout(info);
    info->setAlignment(Qt::AlignCenter);



    //name
    QLabel* name= new QLabel("Name: "+ QString::fromStdString(boarding.getName()));
    info->addWidget(name);

    //date
    QLabel* date= new QLabel("Arrival date: "+ QString::fromStdString(boarding.getDate().toString()));
    info->addWidget(date);

    //Owner
    Owner* owner=boarding.getOwner();
    std::string OwnerName=owner->getName();
    std::string OwnerSurname=owner->getSurname();
    QLabel* ownerString= new QLabel("Owner: " + QString::fromStdString(OwnerName + " " + OwnerSurname));
    info->addWidget(ownerString);


    //Optional services
    QLabel* optionalService= new QLabel("Optional services: ");
    info->addWidget(optionalService);


    QHBoxLayout* srvc= new QHBoxLayout();
    info->addLayout(srvc);


    //Bath
    QLabel* bath= new QLabel();
    QLabel* bathString= new QLabel("Bath");
    bath->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (boarding.didBath())
        bath->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        bath->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    srvc->addWidget(bath);
    srvc->addWidget(bathString);


    //Diet
    QLabel* diet= new QLabel();
    QLabel* dietString= new QLabel("Diet");
    diet->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (boarding.didDiet())
        diet->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        diet->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    srvc->addWidget(diet);
    srvc->addWidget(dietString);


    //Trainings
    QLabel* trainings= new QLabel();
    QLabel* trainString= new QLabel("Trainings");
    trainings->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (boarding.didTraining())
        trainings->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        trainings->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    srvc->addWidget(trainings);
    srvc->addWidget(trainString);


    //Walks
    QLabel* walks= new QLabel();
    QLabel* walksString= new QLabel("Walks");
    walks->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (boarding.didWalking())
        walks->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        walks->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    srvc->addWidget(walks);
    srvc->addWidget(walksString);

    hbox->addStretch();
    hbox->addStretch();



    hbox->addSpacing(25);


    //put all things togheter
    cardLayout= new QVBoxLayout();
    cardLayout->addLayout(hbox);


}



void DogVisitorCard::visitBreeding(Breeding &breeding) {
   

    QHBoxLayout* hbox=new QHBoxLayout();

    hbox->addSpacing(30);

    dog=&breeding;

    //left image
    QHBoxLayout* img= new QHBoxLayout();
    QLabel* image= new QLabel();

    Breed* bulldogPointer=breeding.getBreed();


    if(dynamic_cast<Bulldog*>(bulldogPointer))
        image->setPixmap(QPixmap(":/assets/icons8-french-bulldog-64.png"));
    else
        image->setPixmap(QPixmap(":/assets/icons8-dog-64.png"));


    image->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
    img->addWidget(image);
    hbox->addLayout(img);


    hbox->addSpacing(25);


    //Dog's info
    QVBoxLayout* info= new QVBoxLayout();
    hbox->addLayout(info);
    info->setAlignment(Qt::AlignCenter|Qt::AlignVCenter);


    //name
    QLabel* name= new QLabel("Name: "+ QString::fromStdString(breeding.getName()));
    info->addWidget(name);

    //date
    QLabel* date= new QLabel("Day of birth: "+ QString::fromStdString(breeding.getDate().toString()));
    info->addWidget(date);


    //Breed
    QLabel* breed= new QLabel("Breed: "+QString::fromStdString(breeding.getBreed()->toString()));
    info->addWidget(breed);


    //Optional services
    QLabel* options= new QLabel("Options: ");
    info->addWidget(options);


    QHBoxLayout* opt= new QHBoxLayout();
    info->addLayout(opt);


    //Vax
    QLabel* vax= new QLabel();
    QLabel* vaxString= new QLabel("Vaxxed");
    vax->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (breeding.isVax())
        vax->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        vax->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    opt->addWidget(vax);
    opt->addWidget(vaxString);


    //Purchasable
    QLabel* purch= new QLabel();
    QLabel* purchString= new QLabel("Purchasable");
    purch->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (breeding.isPurchasable())
        purch->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        purch->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    opt->addWidget(purch);
    opt->addWidget(purchString);


    //Booked
    QLabel* booked= new QLabel();
    QLabel* bookedString= new QLabel("Booked");
    booked->setAlignment(Qt::AlignRight|Qt::AlignCenter);

    if (breeding.isBooked())
        booked->setPixmap(QPixmap(":/assets/icons8-done-48.png").scaled(10,10,Qt::KeepAspectRatio));
    else
        booked->setPixmap(QPixmap(":/assets/icons8-close-48.png").scaled(10,10,Qt::KeepAspectRatio));

    opt->addWidget(booked);
    opt->addWidget(bookedString);

    hbox->addStretch();
    hbox->addStretch();


    hbox->addSpacing(25);


    //put all things togheter
    cardLayout= new QVBoxLayout();
    cardLayout->addLayout(hbox);


}

四、程序链接

https://download.csdn.net/download/u013083044/88739503

相关推荐

  1. RK——看门

    2024-01-16 23:14:07       61 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-16 23:14:07       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-16 23:14:07       106 阅读
  3. 在Django里面运行非项目文件

    2024-01-16 23:14:07       87 阅读
  4. Python语言-面向对象

    2024-01-16 23:14:07       96 阅读

热门阅读

  1. redis.conf配置文件常用配置项详解

    2024-01-16 23:14:07       51 阅读
  2. 【Kubernetes】K8s 查看 Pod 的状态

    2024-01-16 23:14:07       53 阅读
  3. CSS笔记

    CSS笔记

    2024-01-16 23:14:07      49 阅读
  4. 常见的排序算法

    2024-01-16 23:14:07       59 阅读
  5. go快速生成二维码

    2024-01-16 23:14:07       56 阅读
  6. Qt获取当前系统网络接口信息

    2024-01-16 23:14:07       52 阅读
  7. Kafka

    2024-01-16 23:14:07       55 阅读
  8. 大模型学习第五课

    2024-01-16 23:14:07       58 阅读
  9. Vue生成图片并下载

    2024-01-16 23:14:07       55 阅读