<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Error: The program has unexpectedly finished.]]></title><description><![CDATA[<p dir="auto">Why after initializing "home" pointer by calling "setupWidgets(home,homepanelShadow,homepanel,50,":/Images/Home.png");<br />
"<br />
it crashes on this statement :- "home-&gt;setStyleSheet("background-color:red;");  // this is where it crashes"<br />
below is the code :-</p>
<p dir="auto"><strong>ramadantimes.cpp</strong></p>
<pre><code>RamadanTimes::RamadanTimes(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::RamadanTimes)
{
    ui-&gt;setupUi(this);
    setupWidgets(home,homepanelShadow,homepanel,50,":/Images/Home.png");
    home-&gt;setStyleSheet("background-color:red;");  // this is where it crashes   
}
void RamadanTimes::setupWidgets(QToolButton *button,QGraphicsDropShadowEffect *panelshadow,
                                   QFrame *panel,int w,QString image){

    button = constructButton(button,w,image);
    panelshadow = createShadow(panelshadow,0,0,5);
    panel = constructFrame(panel,panelshadow);

    if (w != 50)
        panel-&gt;hide();
}


QToolButton *RamadanTimes::constructButton(QToolButton *button,int y,QString image){

    button = new QToolButton(menubar);
    button-&gt;setGeometry(0,y,60,50);
    button-&gt;setIcon(QIcon(image));
    button-&gt;setIconSize(QSize(35,35));
    button-&gt;setToolButtonStyle(Qt::ToolButtonIconOnly);
    button-&gt;setText("Home");
    button-&gt;setAutoRaise(true);
    button-&gt;setAutoRepeat(false);
    button-&gt;setStyleSheet("QToolButton:pressed { background-color: rgb(42,52,62); border:0px;}");
    return button ;
}

QGraphicsDropShadowEffect *RamadanTimes::createShadow(QGraphicsDropShadowEffect *shadow,int x, int y, int radius, QString color){

    shadow = new QGraphicsDropShadowEffect ;
    shadow-&gt;setXOffset(x);
    shadow-&gt;setYOffset(y);
    shadow-&gt;setBlurRadius(radius);
    shadow-&gt;setColor(color);
    return shadow ;
}

QFrame *RamadanTimes::constructFrame(QFrame *frame,QGraphicsDropShadowEffect *shadow){

    frame = new QFrame(this);
    frame-&gt;setGeometry(75,70,515,440);
    frame-&gt;setGraphicsEffect(shadow);
    return frame ;
}

</code></pre>
]]></description><link>https://forum.qt.io/topic/80085/error-the-program-has-unexpectedly-finished</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 11:31:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/80085.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Jun 2017 11:26:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 15:00:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ahti">@<bdi>Ahti</bdi></a> OK, now I understand better. The case is closed.</p>
]]></description><link>https://forum.qt.io/post/398268</link><guid isPermaLink="true">https://forum.qt.io/post/398268</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Thu, 08 Jun 2017 15:00:09 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 14:46:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eeli-k">@<bdi>Eeli-K</bdi></a></p>
<p dir="auto">this is what i mean brother:</p>
<pre><code>setupWidgets(home,homepanelShadow,homepanel,50,":/Images/Home.png");
setupWidgets(settings,settingspanelShadow,settingspanel,150,":/Images/settings.png");
setupWidgets(contact,contactpanelShadow,contactpanel,250,":/Images/Contact.png");
setupWidgets(about,aboutpanelShadow,aboutpanel,350,":/Images/About.png");
</code></pre>
]]></description><link>https://forum.qt.io/post/398264</link><guid isPermaLink="true">https://forum.qt.io/post/398264</guid><dc:creator><![CDATA[Ahti]]></dc:creator><pubDate>Thu, 08 Jun 2017 14:46:26 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 14:01:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ahti">@<bdi>Ahti</bdi></a> I don't understand. What QWidgets you mean? If you have several RamadanTimes objects (which are QMainWindows) they each have their own buttons etc. The main point of objects (and classes) is to encapsulate data and behaviour into one object. The member data of each object can be accessed in member functions so that it doesn't have anything to do with other objects of the same class. Static members are class-wide, shared between objects of the same class. One just shouldn't pass normal data members as arguments to normal member functions because they can be accessed directly by the member functions.</p>
]]></description><link>https://forum.qt.io/post/398256</link><guid isPermaLink="true">https://forum.qt.io/post/398256</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Thu, 08 Jun 2017 14:01:07 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 13:48:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a> Thanks brother :D love you :)</p>
]]></description><link>https://forum.qt.io/post/398249</link><guid isPermaLink="true">https://forum.qt.io/post/398249</guid><dc:creator><![CDATA[Ahti]]></dc:creator><pubDate>Thu, 08 Jun 2017 13:48:44 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 13:43:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eeli-k">@<bdi>Eeli-K</bdi></a> Because i have more QWidgets not just one.</p>
]]></description><link>https://forum.qt.io/post/398246</link><guid isPermaLink="true">https://forum.qt.io/post/398246</guid><dc:creator><![CDATA[Ahti]]></dc:creator><pubDate>Thu, 08 Jun 2017 13:43:04 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 12:56:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ahti">@<bdi>Ahti</bdi></a> VRonin's solution is good if you want to do minimal changes. On the other hand you have strange architecture - why you pass the members as arguments at all to member functions? You could do</p>
<pre><code>void RamadanTimes::setupWidgets(int w,QString image){
home = new QToolButton(menubar);
home-&gt;setGeometry...
// init the button...
panelshadow = new...
// init the shadow...
panel = new...
//init the frame
</code></pre>
]]></description><link>https://forum.qt.io/post/398231</link><guid isPermaLink="true">https://forum.qt.io/post/398231</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Thu, 08 Jun 2017 12:56:32 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 12:42:37 GMT]]></title><description><![CDATA[<p dir="auto">You pass the pointer by value, the <code>button =</code> assignment will not be reflected outside <code>setupWidgets</code></p>
<p dir="auto">change <code>RamadanTimes::setupWidgets(QToolButton *button,QGraphicsDropShadowEffect *panelshadow,QFrame *panel,int w,QString image)</code> to <code>RamadanTimes::setupWidgets(QToolButton*&amp; button,QGraphicsDropShadowEffect*&amp; panelshadow,QFrame*&amp; panel,int w,const QString&amp; image)</code></p>
]]></description><link>https://forum.qt.io/post/398208</link><guid isPermaLink="true">https://forum.qt.io/post/398208</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Thu, 08 Jun 2017 12:42:37 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 12:04:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eeli-k">@<bdi>Eeli-K</bdi></a> qDebug() &lt;&lt; home ; displays "QWidget(0x0)" instead of an address of "home" pointer</p>
]]></description><link>https://forum.qt.io/post/398207</link><guid isPermaLink="true">https://forum.qt.io/post/398207</guid><dc:creator><![CDATA[Ahti]]></dc:creator><pubDate>Thu, 08 Jun 2017 12:04:29 GMT</pubDate></item><item><title><![CDATA[Reply to Error: The program has unexpectedly finished. on Thu, 08 Jun 2017 11:56:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ahti">@<bdi>Ahti</bdi></a> It's probably a problem with your memory management. It looks to me like you have a pointer to a button as a member in RamadanTimes. Follow the values of that pointer variable and each *button variable with qDebug() &lt;&lt; home and qDebug() &lt;&lt; button statements in each function and you may find a problem.</p>
]]></description><link>https://forum.qt.io/post/398204</link><guid isPermaLink="true">https://forum.qt.io/post/398204</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Thu, 08 Jun 2017 11:56:02 GMT</pubDate></item></channel></rss>