# Paraview wiget

**URL:** https://discourse.paraview.org/t/paraview-wiget/1851
**Category:** Development
**Created:** [May 14, 2019, 5:42am UTC](https://discourse.paraview.org/t/paraview-wiget/1851 "2019-05-14T05:42:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Deepen](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/c5a1d2/32.png) [@Deepen](https://discourse.paraview.org/u/Deepen)
#### Post date: [May 14, 2019, 5:42am UTC](https://discourse.paraview.org/t/paraview-wiget/1851/1 "2019-05-14T05:42:56Z")

</div>

Hi,  
I am facing issue while try to create a 3D widget in paraview. While i create a QLabel and make it a child of parent then it is coming at the bottom of parent widget. I want have the image (QLabel) inside the parent. Following is a snippet of code.

myMainWindow::myMainWindow(QWidget\* parentObject, Qt::WindowFlags wflags)  
: Superclass(parentObject, wflags)

{  
Ui::myMainWindow ui;  
ui.setupUi(this);  
setWindowTitle(tr(“Paraview Application”));

lineEdit = new QLineEdit;  
imageLabel = new QLabel(this);  
imageLabel-\>setBackgroundRole(QPalette::NoRole);  
//imageLabel-\>setFrameStyle(QFrame::Box | QFrame::Raised);  
imageLabel-\>setWindowFlag(Qt::Tool);

```
imageLabel->setBackgroundRole(QPalette::Base);

```

imageLabel-\>setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

```
QImageReader reader("C:\\Users\\Z662413\\Desktop\\car1.jpg");

```

newImage = reader.read();

imageLabel-\>setPixmap(QPixmap::fromImage(newImage));

imageLabel-\>setAttribute(Qt::WA\_OpaquePaintEvent);  
imageLabel-\>setAlignment(Qt::AlignHCenter);

// Make a connection to the builtin server  
pqApplicationCore\* core = pqApplicationCore::instance();  
core-\>getObjectBuilder()-\>createServer(pqServerResource(“builtin:”));

// Create render view  
pqRenderView\* view =  
qobject\_cast\<pqRenderView\*\>(pqApplicationCore::instance()-\>getObjectBuilder()-\>createView(  
pqRenderView::renderViewType(), pqActiveObjects::instance().activeServer()));  
pqActiveObjects::instance().setActiveView(view);

// Set it as the central widget

this-\>setCentralWidget(view-\>widget());  
QWidget\* centralWdiget = this-\>centralWidget();  
QLayout\* layout = centralWdiget-\>layout();  
layout-\>addWidget(imageLabel);  
this-\>setCentralWidget(imageLabel);

}

---

<div class="post-metadata">

### Author: ![utkarsh.ayachit](https://discourse.paraview.org/user_avatar/discourse.paraview.org/utkarsh.ayachit/32/39_2.png) [@utkarsh.ayachit](https://discourse.paraview.org/u/utkarsh.ayachit)
#### Post date: [May 14, 2019, 12:15pm UTC](https://discourse.paraview.org/t/paraview-wiget/1851/2 "2019-05-14T12:15:04Z")

</div>

> [@Deepen](#):
>
> this-\>setCentralWidget(view-\>widget());  
> QWidget\* centralWdiget = this-\>centralWidget();  
> QLayout\* layout = centralWdiget-\>layout();  
> layout-\>addWidget(imageLabel);  
> this-\>setCentralWidget(imageLabel);

this seems to strange to me. You’re making the label the central widget?

Also this is simply a Qt thing. I’d recommend referring to Qt docs on [widget layouts](https://doc.qt.io/qt-5/layout.html).

Here’s a snippet to get you started.

```cpp
QWidget* child = new QWidget(this);
QVBoxLayout* vbox = new QVBoxLayout(child);
vbox->addWidget(imageLabel);
vbox->addWidget(view->widget());

this->setCentralWidget(child);

```
