Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在我的应用程序中,我有可以调整大小的矩形(手动实现鼠标事件来调整大小)。我的问题是我可以调整任何大小的矩形。如何实现禁止在 100x100 像素以下调整大小的功能。换句话说,我想要为矩形设置最小尺寸的函数,这样用户就不能在 100x100 像素下调整该矩形的大小。如果需要,我将提供我的部分代码,但现在我需要想法或伪代码。
如果您已经编写了调整矩形大小的代码,那么您只需要添加如下内容:
QRect r = oldRect(); switch (border) { case Left: r.setLeft(newLeftPos()); if (r.width() < minimumWidth()) r.setLeft(r.right() - minimumWidth()); break; ... } draw(r);