简体   繁体   English

Qt GUI:使用鼠标选择多个QLabel

[英]Qt GUI: Select multiple QLabels with mouse

I would like to enable mouse-selection of the text of several QLabels arranged in a grid layout in a Qt GUI. 我想启用鼠标选择Qt GUI中以网格布局排列的多个QLabel的文本。 A QLabel has textInteractionFlags like TextSelectableByMouse which enables this behaviour for one object, but a selection across several QLabel widgets does not seem to work. QLabel具有类似于TextSelectableByMouse的textInteractionFlags,可为一个对象启用此行为,但是跨多个QLabel小部件的选择似乎无效。

Is there a way around this that does not require a lot of mouse "tracking" or reimplementing a layout? 有没有一种方法不需要大量的鼠标“跟踪”或重新实现布局?

I fear there's no simple method to get what you want. 我担心没有简单的方法可以得到想要的东西。 The first problem would be what you'd expect to find in the paste buffer after selecting some rectangular section of your table. 第一个问题是您希望在选择表的某些矩形部分后在粘贴缓冲区中找到什么。 How should the label texts be delimited, should they be organized by row or colum? 标签文本应如何定界,应按行还是按列组织?

You may say that you want them row-wise, columns separated by blanks and rows ending with a \\n, but that doesn't need to be what the next person needs. 您可能会说您希望它们按行排列,用空格分隔的行和以\\ n结尾的行,但这并不一定是下一个需要的人。

You may want to spend some time considering QTableView or QTableWidget. 您可能需要花一些时间考虑使用QTableView或QTableWidget。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM