1

I wrote a program using QvtkWidget. When I successfully embedded QvtkWidget into my GUI. I found the size of my Button is abnormal.

I have already changed the layout. Nothing happened. I use Mac Mojave. Anyone knows something? Many thanks. Here are the results.

normal_in_Qt_creator

abnormal_after_compile

and this are my GUI layouts. I have already put my widget into Layout, Still abnormal size. I tested the codes on windows they work fine. So maybe there is something to do with my Mac Retina Screen.

李宗瑞
  • 13
  • 3
  • If you want `pushbutton` and `qvtkWidget` to be in the same layout, you need to put them into the same layout. In that lower image, `pushButton` is not in any layout. Working with layouts in the Qt widget Designer is a bit clunky, so you may have to experiment a bit. I think you can also move items in that tree view you have screenshots of, that might make ordering them easier than dragging them in the design area. – hyde Jan 17 '19 at 11:34
  • @hyde Thanks for help! It is clunky. I tried the layout I could use. But it just appears abnormal. – 李宗瑞 Jan 17 '19 at 13:37

2 Answers2

0

You need to put your widget in a QLayout. Read also the Qt tutorial how to do that.

In your case, click the right mouse key into the mainwidget and a context menu opens, and you select "Layout" and your desired layout (e.g. grid). Then you should see a proper layout in Qt's Designer without the red traffic-sign symbol over the central widget which is a warning about a missing layout.

falkb
  • 1,294
  • 11
  • 35
  • Thanks for answering! I have already put widget into layout, but still abnormal. – 李宗瑞 Jan 17 '19 at 08:40
  • Please, read my answer again. I have added more explanation. It should help you – falkb Jan 17 '19 at 08:58
  • Thank you. I tried what you said but the widget still got large. I think maybe there is something to do with my Retina screen? Because same codes works fine in Windows. – 李宗瑞 Jan 17 '19 at 11:11
  • I don't really believe it does not help. If you did what I suggested, the red traffic-sign shouldn't be anymore over centralWidget. Do you still see it or not? If you still see it, you likely not have selected the layout via context menu. – falkb Jan 17 '19 at 12:28
  • I didn't see the traffic-sign over the central Widget anymore. Firstly I believed it works. But When I put the QVTKWidget into a new tabWidget(Program Requests), it became abnormal. I have re-edited the question to describe this situation. – 李宗瑞 Jan 17 '19 at 13:33
  • I cannot follow your problem anymore. It's a moving target. If the initial question is answered, mark the answer as solution, and then open a new question for the next question, please. And please, rollback your question to the stage without your tabWidget. – falkb Jan 17 '19 at 14:12
0

I found the issue. QvtkWidget is too old to use. Now use QVTKOpenGLWidget instead. To do that you should promote a OpenGLWidget. Then it works. Hope others won't waste too much time on that like me.

Tips:QVTKOpenGLWidget supports vtkGenericOpenGLRenderWindow. Be sure to that. Here is an example. (So Grateful) http://www.pcl-users.org/QVTKOpenGLWidget-Qt-PCLVisualizer-td4045158.html

李宗瑞
  • 13
  • 3