c++ - 隐藏 vtkOutputWindow

标签 c++ qt vtk qvtkwidget

如何隐藏 vtkOutputWindow?没有压制 GlobalWarningDisplayOff() 或将输出重定向到文件,但仅 隐藏。 (并在一段时间后通过 vtkOutputWindow::GetInstance()->DisplayText("") 之类的内容再次显示)。谢谢。

附言。我在 Windows 上使用 Qt gui。

PPS。对于那些对此问题感兴趣的人,我将邮件列表信件带到这里( super 链接尚不可用):

贝尔,好的!现在我明白你的意思了。正如您所说,最简单的方法可能是向窗口发送关闭信号。

正如您在 vtkWin32OutputWindow 引用 (https://www.vtk.org/doc/nightly/html/classvtkWin32OutputWindow.html) 中看到的那样,它是“一个只读的 EDIT 控件”,因此如果您能获得它的句柄,也许您可​​以将它合并到您可以控制的窗口中。 另一个更复杂的解决方案是创建一个新类,该类继承自 vtkOutputWindow,基于 vtkWin32OutputWindow,但带有隐藏和显示控件的控件。 最好的问候, Lucas Frucht Desenvolvimento

Lucas, thanks for reply. I don't need to "save changes" while vtkOutputWindow is hidden. In generally my question is about how to hide/show this window from gui in runtime. vtkOutputWindow class is not derived from any widget so it havn't any method like "hide" or "close". Also destroy it not help too.

vtkOutputWindow *w =  vtkOutputWindow::GetInstance();
w->Delete();
... (redirecting...) 

don't close it. It seem to sending close signal to window is the simplest solution.

Sincerely, Bel. 08.08.2018 18:04, lucas.frucht@medilabsistemas.com.br: >

Bel, There is one point that is not clear to me in your question. Do you want the messages that would have been shown when vtkOutputWindow is hidden to be discarded or to be shown when you unhide it?

If you want it to be discarded, I suppose you could redirect it to /dev/null on Unix or to nul on Windows and delete the redirection when you want to unhide the window.

If you just want to delay the output, maybe, you could redirect the messages to an vtkStringOutputWindow to store the messages on a string and when you want to show then, delete the redirection and call DisplayText passing the string where you stored the messages. I never tried this, but it seems reasonable to me. Best regards, Lucas Frucht.

最佳答案

在 Windows 上,这可能会起作用(不过我还没有测试过)。

vtkSmartPointer<vtkWin32OutputWindow> outputWindow = vtkSmartPointer<vtkWin32OutputWindow>::New(); 
outputWindow->SetSendToStdErr(true);
vtkOutputWindow::SetInstance(outputWindow);

输出消息将被定向到 stderr 而不是输出窗口。要再次打开它,请禁用重定向。其他可能性包括 subclassing of vtkOutputWindow或到 install an observer用于满足您需要的错误事件。

发布了类似的问题 here .

关于c++ - 隐藏 vtkOutputWindow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51742720/

相关文章:

c++ - 强制调用构造函数而不是函数式转换

c++ - 函数类型的模板对象

c++ - focusOutEvent 未被调用

c++ - 使两个物体朝向同一方向(计算机可视化)

c++ - 工厂方法说明

c++ - 如何检查对象的类型是否是 C++ 中的特定子类?

c++ - 为了让 QtSql 正常运行,我需要哪些 .dll 文件?

C++ 使这个 Djikstra 实现更快

c++ - vtk IntersectWithLine() 函数使用法线作为线

c++ - Qt 不支持 VTK 库