QWizardPages 保持自己的最小尺寸

发布于 2024-09-14 10:32:55 字数 728 浏览 1 评论 0原文

我正在使用 Qt(Windows XP 32 位上的版本 4.6,并在 Qt Creator 2.0.0 中编译)并尝试让 QWizard 来工作。

第一个问题

到目前为止,我的QWizard中有三个QWizardPages。每个页面都应用了 QVBoxLayout 作为其布局。我的第一页内容非常小(只有三行 QLabel),但由于某种原因,QLabel 和“< Back”、“Next >”之间有相当多的空白。和“取消”按钮窗格。我希望每个页面根据其内部内容具有最少的空白。过去,当我将 QVBoxLayout 放入无父 QWidget(它自己的窗口)中时,窗口总是足够小以修复 QVBoxLayout。现在有额外的空白。是否有一些选项我必须关闭或打开,以便 QWizardPages 尽可能小?

第二页(很可能与第一页相关)问题

另外,我的第二页比第一页大得多,所以当我到达第二页并返回时到第一页,第一页保持与第二页相同的大小,但只有在我访问第二页之后。这是一个错误吗?

执行 a 时

move(50, 50);

我所做的唯一几何设置是在 QWizard 构造函数中 。没有调整大小...没有明确的内容。我试图让布局发挥其魔力。

感谢您的提前帮助。

I'm working with Qt (version 4.6 on Windows XP 32-bit and compiling in Qt Creator 2.0.0) and trying to get a QWizard to work out.

First Problem:

I have three QWizardPages in my QWizard so far. Each page has a QVBoxLayout applied as it's layout. My first page has very small content (just a three line QLabel) but for some reason there is quite a bit of white space between the QLabel and the "< Back", "Next >" and "Cancel" button pane. I want each page to have the minimum amount of white space based on the content inside it. In the past, when I've put a QVBoxLayout in a parentless QWidget (it's own window), the window was always just small enough to fix the QVBoxLayout. Now there is extra whitespace. Is there some option that I have to turn off or on so that the QWizardPages are as small as possible?

Second (and mostly likely related to the first) Problem:

Also, my second page is much larger than my first page, so when I get to the second page and come back to the first page, the first page maintains the same size as the second page but only after I have visited the second page. Is this a bug?

The only geometry setting I am doing is when I do a

move(50, 50);

in the QWizard constructor. No resizes... nothing explicit. I'm trying to let the layouts do their magic.

Thanks for your help in advanced.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中二柚 2024-09-21 10:32:55

为了解决这个问题,我创建了 QWizard 的子类并创建了一个如下所示的私有插槽:

void ChildClass::fitContents(int id)
{
    adjustSize(); // this automagically resizes the window to fit the contents
}

并使其在每次页面更改时调用它,如下所示:

connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(fitContents(int)));

To fix this problem, I created a child class of QWizard and created a private slot like this:

void ChildClass::fitContents(int id)
{
    adjustSize(); // this automagically resizes the window to fit the contents
}

And made it had it called every time the page was changed, like so:

connect(this, SIGNAL(currentIdChanged(int)), this, SLOT(fitContents(int)));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文