English 中文(简体)
• 如何使QMdiArea亚温德植被无法使用?
原标题:How to make a QMdiArea subwindow widget non-resizeable?

因此,我代码的非<代码>QMdiArea版本,

MyWidget::MyWidget(QWidget* parent)
{
   ...
   layout()->setSizeConstraint( QLayout::SetFixedSize );
}

MainWindow::MainWindow(...)
{
   ...
   MyWidget* wgt = new MyWidget(NULL);
   wgt->show();
}

只做罚款,并生产用户可以转售的植被。 但是,当<代码>MainWindow代码被替换时,则代之以

MainWindow::MainWindow(...)
{
   ...
   MyWidget* wgt = new MyWidget(ui->mdiArea); //Or MyWidget(NULL), same result
   ui->mdiArea->addSubWindow(wgt);
}

现在列在<代码>QMdiArea内的窗户可变。 这似乎只是一个Qt的问题:WindowFlags, 他们没有处理转民政策。 确实有这样做的方法? NB I cant use some such as setFixedSize(ht, wd),因为植被的规模可以有计划地改变(添加和删除次级目标)。 但是,用户不应能够加以改造。

最佳回答

The following worked for me:

    MyWidget* wgt = new MyWidget(ui->mdiArea); 
    QMdiSubWindow* subWindow = ui->mdiArea->addSubWindow(wgt); 
    subWindow->setFixedSize(wgt->size());
    wgt->show();
问题回答

即便是<代码>MyWidget,在你要求时,也不可变:

ui->mdiArea->addSubWindow(wgt);

植被载于http://developer.qt.nokia.com/doc/qt-4.8/qmdisubwindow.html“rel=“nofollow”>QMdiSubWindow,is。 你们必须做的是获得创造和固定其规模的窗口:

QMdiSubWindow* subWindow = ui->mdiArea->addSubWindow(wgt);
subWindow->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

This should work, but I haven t tried this code myself.

EDIT: 似乎有doesn t 固定尺寸:





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签