# \[QtRoot\] TQtWidget::Refresh() causes segmentation fault

**URL:** <https://root-forum.cern.ch/t/qtroot-tqtwidget-refresh-causes-segmentation-fault/14551>\
**Category:** ROOT\
**Created:** [July 9, 2012, 5:38pm UTC](https://root-forum.cern.ch/t/qtroot-tqtwidget-refresh-causes-segmentation-fault/14551 "2012-07-09T17:38:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 12, 2012, 11:32pm UTC](https://root-forum.cern.ch/t/qtroot-tqtwidget-refresh-causes-segmentation-fault/14551/6 "2012-07-12T23:32:10Z")

</div>

[quote=“arobicha”] … it works properly (beautifully, as a matter of fact) …[/quote] 😃

[quote=“arobicha”]Thanks very much for the info on Qt, and coding practices therein. That actually makes the whole thing worth while, regardless of whether I fix this.  
I implemented all the changes you suggested,[/quote]Did you follow my[quote=“fine”]In addition you are recommended to install ( follow to "Complement the existent ROOT installation with QtRoot plugin [qtroot.svn.sourceforge.net/viewv … tExamples/](http://qtroot.svn.sourceforge.net/viewvc/qtroot/trunk/qtExamples/) ) which is the collection of HelloWorld-level working QtRoot applications addressing all QtRoot use cases I have encountered.[/quote] to build your application against of that plugin?[quote=“arobicha”]it works properly … on the second execution.[/quote] ![#-o](https://root-forum.cern.ch/uploads/default/original/1X/378b417f7f25e635458e14f511257ba15acc7a37.gif "d'oh!") May I ask you ![[-o<](https://root-forum.cern.ch/uploads/default/original/1X/1566ef0d78260b997b270229fbe0e2bf7bbab46f.gif "Pray") to try what I recommended to see whether it makes any difference. It should take you 5-10 min to complete.

Also may I ask you to try with your existing system the slightly different version of the MainWindows as follows:[code]#include “MainWindow.h”  
#include “ui\_MainWindow.h”  
#include “TList.h”

MainWindow::MainWindow(QWidget _parent) :  
QMainWindow(parent),  
ui(new Ui::MainWindow),  
g()  
{  
ui-\>setupUi(this);  
Int\_t x[5], y[5];  
for(int i=0; i\<5; i++)  
{  
x[i] = i; y[i]=i_i;  
}  
g = new TGraph(sizeof(x)/sizeof(float),x,y);  
g-\>SetBit(kMustCleanup);  
TPad \*p = ui-\>widget-\>GetCanvas();  
p-\>GetListOfPrimitives()-\>Add(g);  
}  
MainWindow::~MainWindow()  
{ }[/code]to remove the ROOT “rendering” from the widget ctor ( it is redundant anyway. So your application will work faster )  
Check this post [Compile root with Qt but without dependence on libQtWebKit](https://root-forum.cern.ch/t/compile-root-with-qt-but-without-dependence-on-libqtwebkit/14567/1) too

---

_[View the full topic](https://root-forum.cern.ch/t/qtroot-tqtwidget-refresh-causes-segmentation-fault/14551)._
