布局管理杂记

1
2
3
4
5
6
m_pVBoxLayout->setContentsMargins (20, 20, 20, 20);
m_pVBoxLayout->addWidget(m_topCaptionButton);  //1
m_pVBoxLayout->addWidget(m_pShadowDialog);  //2
m_pVBoxLayout->setSpacing(15);
m_pVBoxLayout->addLayout (m_pHBoxLayoutButton);  //3
m_pVBoxLayout->addStretch();

1与2的间隔,应是默认的spacing。而2与3的间隔,应是设进去的15。

  1. QVBoxLayout *buttonLayout = new QVBoxLayout;  
  2. buttonLayout->addStretch(1);  
  3. buttonLayout->addWidget(Button1);  
  4. buttonLayout->addStretch(1);  
  5. buttonLayout->addWidget(Button2);  
  6. buttonLayout->addStretch(1);  
  7. buttonLayout->addWidget(Button3);  
  8. buttonLayout->addStretch(6);  

buttonLayout的布局将空白没有widget的地方分成了9份,然后按照您所规定的地方分配弹簧,

game_mode_button->setCursor(Qt::PointingHandCursor);//设置光标状态

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要将图书管理系统的文件存入链表,需要进行以下步骤: 1. 定义一个图书的结构体,包含图书的相关信息,例如书名、作者、ISBN等。 2. 创建一个链表节点的结构体,包含一个指向图书结构体的指针和一个指向下一个链表节点的指针。 3. 创建一个链表的头节点,并初始化为NULL。 4. 打开图书管理系统的文件,读取每一本图书的信息。 5. 为每一本图书创建一个链表节点,并将读取到的图书信息存入该节点的图书结构体中。 6. 将新创建的链表节点插入到链表中合适的位置,可以按照图书的ISBN号进行排序。 7. 重复步骤4-6,直到读取完所有的图书信息。 8. 关闭文件。 以下是一个示例代码,用于将图书管理系统的文件存入链表(假设文件中每行记录包含图书的名称和作者,以逗号分隔): ```c #include <stdio.h> #include <stdlib.h> #include <string.h> // 定义图书结构体 typedef struct { char name[100]; char author[100]; } Book; // 定义链表节点结构体 typedef struct Node { Book book; struct Node* next; } Node; // 插入新节点到链表中 void insertNode(Node** head, Book book) { Node* newNode = (Node*)malloc(sizeof(Node)); newNode->book = book; newNode->next = NULL; if (*head == NULL) { *head = newNode; } else { Node* current = *head; Node* previous = NULL; while (current != NULL && strcmp(book.name, current->book.name) > 0) { previous = current; current = current->next; } if (previous == NULL) { newNode->next = *head; *head = newNode; } else { previous->next = newNode; newNode->next = current; } } } // 打印链表中的图书信息 void printList(Node* head) { Node* current = head; while (current != NULL) { printf("书名:%s,作者:%s\n", current->book.name, current->book.author); current = current->next; } } int main() { Node* head = NULL; FILE* file = fopen("books.txt", "r"); if (file == NULL) { printf("无法打开文件!\n"); return 1; } char line[200]; char name[100], author[100]; while (fgets(line, sizeof(line), file)) { sscanf(line, "%[^,], %[^\n]", name, author); Book book; strcpy(book.name, name); strcpy(book.author, author); insertNode(&head, book); } fclose(file); printList(head); return 0; } ``` 请注意,此代码仅提供了一个基本的示例,实际应用中可能需要根据具体需求进行调整和扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值