RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-365798

novol's questions

Martin Hope
novol
Asked: 2021-10-11 01:47:24 +0000 UTC

如何调用字符串格式的函数

  • 1

我使用类获取图像

class ImageLoader extends StatefulWidget{
  final String imageBytes;
  final Brand brand;

  const ImageLoader({Key key, this.imageBytes, this.brand}) : super(key: key);

  @override
  Widget build(BuildContext context, index){
    _ImageLoaderState();
  }

  @override
  _ImageLoaderState createState() => _ImageLoaderState();
}

class _ImageLoaderState extends State<ImageLoader> {

  final FirebaseStorage storage = FirebaseStorage(
      storageBucket: 'gs://any.appspot.com');

  String errorMsg;
  String imageBytes;

  _ImageLoaderState() {
    storage.ref().child('images/image.jpeg').getDownloadURL().then((url) =>
        setState(() {
          imageBytes = url;
        })
    ).catchError((e) =>
        setState(() {
          errorMsg = e.error;
        })
    );
  }

  @override
  void initState() {
    super.initState();
    imageBytes = widget.imageBytes;
  }

  @override
  Widget build(BuildContext context) {
    return Container(child: Image.network(imageBytes, fit: BoxFit.fill,));
  }
}

如何使用数据文件调用图像?

调用图像路径对我来说看起来像这样'${brand.model[0].model_image.image}'

以images/folder/image.jpeg格式返回图像的路径

当我尝试添加${brand.model[0].model_image.image}到孩子时,我storage.ref().child('images/image.jpeg').getDownloadURL().then((url)得到错误品牌未初始化但是当我尝试初始化品牌时,我得到(url = null)

一般来说,我正在尝试获取'gs://any.appspot.com' + '${brand.model[0].model_image.image}'特定图像的链接,以便我的 ListView.builder 将显示给定索引的图像

谢谢你的帮助

firebase
  • 1 个回答
  • 10 Views
Martin Hope
novol
Asked: 2020-08-13 20:11:35 +0000 UTC

颤动如何将信息从数据文件传递到构建器

  • 0

我有一个构建 GestureDetector 的 GridView.bulder,单击每个我用 [index] 导航详细信息。在每个 GestureDetector 中还有一个带有 GestureDetector 的列表,但是在这里我不明白如何打开绑定到原始 [index] 的特定数据文件,我试图在这样的列表中创建一个列表

class Brand {
  final String image, title;
  final int id;
  final List <Subject> subjects;

  Brand({
    this.id,
    this.image,
    this.title,
    this.subjects,
  });
}

class Subject {

  final int acura_id;
  final String acura_image, acura_title;

  Subject({
    this.acura_id,
    this.acura_image,
    this.acura_title,
  });
}

List<Brand> brands = [
  Brand(
    id: 1,
    title: "ACURA",
    image: "images/acura-logo.png",
    subjects: [
      Subject(
        acura_id: 1,
        acura_image: "images/acura/ilx.png",
        acura_title: "ILX"
      ),
      Subject(
        acura_id: 2,
        acura_image: "images/acura/rdx.png",
        acura_title: "RDX"
      ),
    ],
  ),
 ];

但是当被调用时,它"${brand.subjects.acura_id}"会给出一个错误:getter 'acura_id' 没有为类型'List' 定义。(undefined_getter at [save_me] lib/cars_name.dart:43) 也许我用错了方式,如果你能帮助我理解为什么我不能调用列表或告诉我用哪种方式更改代码,我将不胜感激

flutter
  • 1 个回答
  • 10 Views
Martin Hope
novol
Asked: 2020-12-29 20:39:23 +0000 UTC

在 PyQt5 中编写条件

  • 1

在每位患者附近都会有一个按钮Выселить,按下该按钮可以在出院时将患者逐出病房,这将从患者数据库中删除他的姓名以释放空间。

患者的分布将按年龄划分,分为两个年龄类别:

  • 18-45岁
  • 46+:

在每个房间中,将计算患者的平均年龄,视情况而定,18-45岁年龄组的患者将被分配到患者平均年龄低于45岁的房间,46岁以上年龄组的患者将被分配到分配到患者平均年龄在45岁以上的病房,但前提是此类病房有空位。

如果没有按年龄划分的患者住宿选择,他们将被安置在与其性别对应的房间内的任何免费床位上,但需视供应情况而定。

如果根本没有空位,病人就会被安置在走廊里,并会出现相应的信息:“没有空位。病人(病人资料)将被安置在大厅。

安置在大厅的病人名单将显示在每个科室的房间列表下方,标题为“临时住宿(大厅)”,格式与病房病人名单类似,但没有“驱逐”按钮将有一个“安置在病房”按钮,通过手动选择允许重新安置患者的空置病房的编号,可以将患者安置在病房而不是大厅。

在此处输入图像描述

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLineEdit, \
    QTableView, QGridLayout, QListWidget, QLabel, QListView, QTabWidget, QFrame, \
    QHeaderView, QFormLayout                                                        # +++
from PyQt5.QtCore import *
from PyQt5.QtGui import *


class Example(QWidget):
    def __init__(self):
        super().__init__()

        self.table = QTableView(self)
        self.model = QStandardItemModel()
        self.table.setModel(self.model)
        self.model.setHorizontalHeaderLabels(["Имя", "Пол", "Возраст", "Отделение", "Диагноз", "Палата"])

        self.table.setAlternatingRowColors(True)                                    # +
        self.table.horizontalHeader().setSectionResizeMode(4, QHeaderView.Stretch)  # +

        self.btn = QPushButton("Отправить")
        self.btn.clicked.connect(self.add)

        self.years = QLabel('Возраст', alignment=Qt.AlignRight | Qt.AlignVCenter)
        self.years.setMaximumWidth(60)
        self.years_line = QLineEdit(placeholderText='Введите возраст...')
        self.diagnose_line = QLineEdit(placeholderText='Введите диагноз...')
        self.diagnose = QLabel('Диагноз', alignment=Qt.AlignRight | Qt.AlignVCenter)
        self.otd_line = QLineEdit(placeholderText='Введите отделение...')
        self.otd = QLabel('Отделение', alignment=Qt.AlignRight | Qt.AlignVCenter)
        self.gender_line = QLineEdit(placeholderText='Введите пол...')
        self.gender = QLabel('Пол', alignment=Qt.AlignRight | Qt.AlignVCenter)
        self.name_line = QLineEdit(placeholderText='Введите имя...')
        self.name = QLabel('Имя', alignment=Qt.AlignRight | Qt.AlignVCenter)
        self.init()

    def init(self):
        grid = QGridLayout(self)
        grid.addWidget(self.name, 1, 0)
        grid.addWidget(self.name_line, 1, 1, 1, 3)
        grid.addWidget(self.gender, 2, 0)
        grid.addWidget(self.gender_line, 2, 1, 1, 3)
        grid.addWidget(self.years, 3, 0)
        grid.addWidget(self.years_line, 3, 1, 1, 3)
        grid.addWidget(self.otd, 4, 0)
        grid.addWidget(self.otd_line, 4, 1, 1, 3)
        grid.addWidget(self.diagnose, 5, 0)
        grid.addWidget(self.diagnose_line, 5, 1, 1, 3)
        grid.addWidget(self.btn, 6, 1, 1, 3) #, 1, -10)
        grid.addWidget(self.table, 7, 0, 5, 4)

def add(self):
    p = 45
    i = 0
    rows = self.model.rowCount()
    columns = self.model.columnCount()
    for column in range(columns):
        if column == 0:
            self.model.setItem(rows, column, QStandardItem(self.name_line.text()))
        if column == 1:
            self.model.setItem(rows, column, QStandardItem(self.gender_line.text()))
        if column == 2:
            self.model.setItem(rows, column, QStandardItem(self.years_line.text()))
        if column == 3:
            self.model.setItem(rows, column, QStandardItem(self.otd_line.text()))
        if column == 4:
            self.model.setItem(rows, column, QStandardItem(self.diagnose_line.text()))
        if column == 5:
            if self.years_line <= p:
                self.table.item(self.model.index(i, 5), "1")
        if column == 6:
            self.table.setIndexWidget(self.model.index(i, 6), self.del_btn)

        self.name_line.clear()
        self.diagnose_line.clear()
        self.otd_line.clear()
        self.years_line.clear()
        self.gender_line.clear()


if __name__ == '__main__':
    app = QApplication(sys.argv)
    app.setStyle("Fusion")
    ex = Example()
    ex.resize(700, 500)
    ex.setWindowTitle('Больница')
    ex.setWindowIcon(QIcon('key.png'))
    ex.show()
    sys.exit(app.exec_())
python
  • 1 个回答
  • 10 Views
Martin Hope
novol
Asked: 2020-12-29 00:45:52 +0000 UTC

如何将输入从 QLineEdit 传递到 QTableView?

  • 1

如何将输入的数据传输QLineEdit到表格中QTableView?

在此处输入图像描述

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLineEdit, \
    QTableView, QGridLayout, \
    QLabel
from PyQt5.QtCore import *
from PyQt5.QtGui import *


class Example(QWidget):
  def __init__(self):
    super().__init__()

    self.table = QTableView(self)
    self.model = QStandardItemModel()
    self.table.setModel(self.model)
    self.model.setHorizontalHeaderLabels(["Имя", "Палата"])
    self.btn = QPushButton("Отправить", self)
    self.years = QLabel('Возраст')
    self.years_line = QLineEdit()
    self.diagnose_line = QLineEdit()
    self.diagnose = QLabel('Диагноз')
    self.otd_line = QLineEdit()
    self.otd = QLabel('Отделение')
    self.gender_line = QLineEdit()
    self.gender = QLabel('Пол')
    self.name_line = QLineEdit()
    self.name = QLabel('Имя')
    self.init()

def init(self):
    grid = QGridLayout()
    self.setLayout(grid)

    self.name.setAlignment(Qt.AlignCenter)
    self.name_line.setPlaceholderText('Введите имя...')
    grid.addWidget(self.name, 1, 1)
    grid.addWidget(self.name_line, 2, 1)

    self.gender.setAlignment(Qt.AlignCenter)
    self.gender_line.setPlaceholderText('Введите пол...')
    grid.addWidget(self.gender, 3, 1)
    grid.addWidget(self.gender_line, 4, 1)

    self.years.setAlignment(Qt.AlignCenter)
    self.years_line.setPlaceholderText('Введите возраст...')
    grid.addWidget(self.years, 5, 1)
    grid.addWidget(self.years_line, 6, 1)

    self.otd.setAlignment(Qt.AlignCenter)
    self.otd_line.setPlaceholderText('Введите отделение...')
    grid.addWidget(self.otd, 7, 1)
    grid.addWidget(self.otd_line, 8, 1)

    self.diagnose.setAlignment(Qt.AlignCenter)
    self.diagnose_line.setPlaceholderText('Введите диагноз...')
    grid.addWidget(self.diagnose, 9, 1)
    grid.addWidget(self.diagnose_line, 10, 1)

    self.table.move(10, 100)
    self.table.resize(517, 400)
    grid.addWidget(self.table, 12, 1, 5, 1)

    grid.addWidget(self.btn, 11, 1, 1, -10)
    self.btn.clicked.connect(self.add)

    self.resize(700, 500)
    self.setWindowTitle('?')
    self.setWindowIcon(QIcon('key.png'))
    self.show()

def add(self):
    model = QStandardItemModel(4, 4)
    for row in range(4):
        for column in range(4):
            item = QStandardItem("row %d, column %d" % (row, column))
            model.setItem(row, column, item)
    self.name_line.clear()
    self.diagnose_line.clear()
    self.otd_line.clear()
    self.years_line.clear()
    self.gender_line.clear()


if __name__ == '__main__':
app = QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
python
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5