[Android开发从零开始].13.Table_Layout学习

表格布局是一个ViewGroup以表格显示它的子视图(view)元素,即行和列标识一个视图的位置。Android的表格布局跟HTML中的表格布局非常类似,TableRow 就像HTML表格的标记。

TableLayout常用的属性
 android:collapseColumns:隐藏指定的列
 android:shrinkColumns:收缩指定的列以适合屏幕,不会挤出屏幕
 android:stretchColumns:尽量把指定的列填充空白部分
 android:layout_column:控件放在指定的列
 android:layout_span:该控件所跨越的列数

源码

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TableRow>
        <Button
            android:text="Button11"
            />
        <Button
            android:text="Button12"
            />
        <Button
            android:text="Button13"
            />
    </TableRow>
    <TableRow>
        <Button
            android:text="Button21"
            />
        <Button
            android:layout_span="2"
            android:text="Button23"
            />
    </TableRow>

</TableLayout>

显示效果:
这里写图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
class MainWindow(QMainWindow): def init(self): super().init() self.setFixedSize(800, 600) main_layout = QVBoxLayout() central_widget = QWidget() central_widget.setLayout(main_layout) self.setCentralWidget(central_widget) button_layout = QVBoxLayout() button1 = QPushButton('当日员工工资') button1.setFixedSize(200, 50) button1.clicked.connect(self.show_query1_result) button_layout.addStretch() button_layout.addWidget(button1) button_layout.addStretch() layout = QHBoxLayout() layout.addStretch() layout.addLayout(button_layout) layout.addStretch() widget = QWidget() widget.setLayout(layout) self.setCentralWidget(widget) main_layout.addLayout(button_layout) self.query1_window = QueryResultWindow() def show_query1_result(self): db = pymysql.connect(host='39.99.214.172', user='root', password='Solotion.123', db='jj_tset') cursor = db.cursor() db_sql = """ """ cursor.execute(db_sql) result = cursor.fetchall() db.close() if len(result) == 0: QMessageBox.information(self, "提示", "今日无员工工资记录") return self.query1_window.table_widget.setRowCount(0) self.query1_window.table_widget.setColumnCount(len(result[0])) self.query1_window.table_widget.setHorizontalHeaderLabels( ["员工ID", "员工姓名", "日期", "领取鸡爪重量(KG)", "效率(每小时KG)", "出成率", "基础工资", "重量奖励", "当日总工资"]) for row_num, row_data in enumerate(result): self.query1_window.table_widget.insertRow(row_num) for col_num, col_data in enumerate(row_data): self.query1_window.table_widget.setItem(row_num, col_num, QTableWidgetItem(str(col_data))) self.query1_window.show() class QueryResultWindow(QWidget): def init(self): super().init() self.setFixedSize(800, 600) self.table_widget = QTableWidget() self.table_widget.setEditTriggers(QTableWidget.NoEditTriggers) self.table_widget.setSelectionBehavior(QTableWidget.SelectRows) layout = QVBoxLayout() layout.addWidget(self.table_widget) self.setLayout(layout) if name == 'main': app = QApplication(sys.argv) loginWindow = LoginWindow() loginWindow.show() sys.exit(app.exec_()))数据展示页面怎么设置筛选器按ID筛选结果并展示的整体代码
05-24

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值