重新运行程序时如何查看禁用按钮被禁用
我创建了很多 qpushbutton
来代表电影院的座位。用户购买座位后,我将这些座位禁用。我想做的就是看到以前禁用的按钮被禁用。我将此禁用按钮保存到 txt 文件并读取其名称,但无法将其指定为我的小部件 Qpushbuttons。有办法解决吗?
I created so much qpushbutton
to represent the seat in the cinema. After user buy the seats I made these seats disabled. all I want to do is to see previously disabled button disabled. I saved this disabled button to a txt file and read their name but I could not assign it as my widget Qpushbuttons. Is there a way to solve it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这与其说是一个按钮问题,不如说是一个数据结构问题。您应该以某种方式将您的按钮/座位连接到一个数据结构,该数据结构有助于记录可用和保留的座位。关闭程序后,会将数据写入文件或数据库,随后在打开应用程序时可以再次读取这些数据。然后,您可以再次禁用预留座位的按钮。
This is not as much a button issue as it is a data structure issue. You should somehow connect your buttons/seats to a data structure which aids in the bookkeeping of available and reserved seats. Once you close the program, you write out the data to a file or database, which you can subsequently read again when you open your application. You can then disable the buttons again of those seats which are reserved.
我用 Qt 做了一些简单的例子,我希望这会对您有所帮助:
这当然只是一个简单的解决方案,使用 QDataStream 序列化完整的座位列表,但如果您是 Qt/新手,您可以尝试一下C++
I've made some quick example with Qt, I hope this will help you:
This is off course just a simple solution using a QDataStream to serialize the complete List of seats, but you can play around with this if you are new to Qt/C++