<?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[Why does not the icon appear on the button?]]></title><description><![CDATA[<p dir="auto">I do in QTableView, a button with the help of delegates, but why the icon on the button is not displayed.<br />
Code:</p>
<pre><code>...
    //paint
    void ButtonDeleteColumnDelegate::paint(QPainter *painter, const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index) const
    {
        QStyleOptionButton button;
        QRect r = option.rect;//getting the rect of the cell
        int x,y,w,h;
        x = r.left() + r.width() - 32;//the X coordinate
        y = r.top();//the Y coordinate
        w = 32;//button width
        h = 32;//button height
        button.rect = QRect(x,y,w,h);
        //button.text = "Удалить запись и файл";

        button.icon = QIcon(":/mapicons/deleting.png");;
        button.iconSize = QSize(32,32);
        button.state = QStyle::State_Enabled;
        QApplication::style()-&gt;drawControl( QStyle::CE_PushButton, &amp;button, painter);
    }
    //updateGeometry
    bool ButtonDeleteColumnDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index)
    {
        if( event-&gt;type() == QEvent::MouseButtonRelease )
        {
            QMouseEvent * e = (QMouseEvent *)event;
            int clickX = e-&gt;x();
            int clickY = e-&gt;y();

            QRect r = option.rect;//getting the rect of the cell
            int x,y,w,h;
            x = r.left() + r.width() - 32;//the X coordinate
            y = r.top();//the Y coordinate
            w = 32;//button width
            h = 32;//button height

            if( clickX &gt; x &amp;&amp; clickX &lt; x + w )
                if( clickY &gt; y &amp;&amp; clickY &lt; y + h )
                {
                    DialogDeleteROW-&gt;setWindowTitle(tr("Удалить запись и файл"));

                    Id = model-&gt;data(model-&gt;index(index.row(),0)).toString();
                    NameFile = model-&gt;data(model-&gt;index(index.row(),1)).toString();
                    if (DisplayMethod == "data") {
                        File = model-&gt;data(model-&gt;index(index.row(),2)).toString();
                    }
                    modelDeleteRow = model;
                    DeleteRow = index.row();
                    IdLineEdit-&gt;setText(model-&gt;data(model-&gt;index(index.row(),0)).toString());
                    FileNameLineEdit-&gt;setText(model-&gt;data(model-&gt;index(index.row(),1)).toString());
                    IdLineEdit-&gt;setEnabled(false);
                    FileNameLineEdit-&gt;setEnabled(false);
                    QLabel *FileNameLabel;
                    if (DisplayMethod == "data") {
                        FileNameLabel = new QLabel(tr("Название файла."));
                    } else if (DisplayMethod == "analysis") {
                        FileNameLabel = new QLabel(tr("Поле сведенья."));
                    }
                    layout-&gt;addWidget(IdLabel,0,0);
                    layout-&gt;addWidget(FileNameLabel,1,0);
                    layout-&gt;addWidget(IdLineEdit,0,1);
                    layout-&gt;addWidget(FileNameLineEdit,1,1);

                    connect(DeleteButton,SIGNAL(clicked(bool)),SLOT(DeleteFunction()));
                    layout-&gt;addWidget(DeleteButton,2,0,1,2);
                    DialogDeleteROW-&gt;setLayout(layout);
                    QRect screenGeometry = QApplication::desktop()-&gt;screenGeometry();
                    int x = (screenGeometry.width() - DialogDeleteROW-&gt;width()) / 2;
                    int y = (screenGeometry.height() - DialogDeleteROW-&gt;height()) / 2;
                    DialogDeleteROW-&gt;move(x,y);
                    DialogDeleteROW-&gt;show();
                }
        }

        return true;
    }
    ...
</code></pre>
<p dir="auto">The pictures are Observation Log \ map icons \ deleting.png</p>
]]></description><link>https://forum.qt.io/topic/92160/why-does-not-the-icon-appear-on-the-button</link><generator>RSS for Node</generator><lastBuildDate>Mon, 09 Nov 2026 11:10:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/92160.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 30 Jun 2018 21:44:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Why does not the icon appear on the button? on Sat, 30 Jun 2018 22:56:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
you have to put the icons in a resource file.<br />
It seems you have just added the images as "other files"<br />
For the ":/path/image.png" syntax to work, they must be in qresource file.<br />
<a href="http://www.bogotobogo.com/Qt/Qt5_Resource_Files.php" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.bogotobogo.com/Qt/Qt5_Resource_Files.php</a></p>
]]></description><link>https://forum.qt.io/post/466769</link><guid isPermaLink="true">https://forum.qt.io/post/466769</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 30 Jun 2018 22:56:20 GMT</pubDate></item><item><title><![CDATA[Reply to Why does not the icon appear on the button? on Sat, 30 Jun 2018 22:11:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> or put a standard icon ```<br />
QStyle::SP_TrashIcon</p>
<pre><code></code></pre>
]]></description><link>https://forum.qt.io/post/466766</link><guid isPermaLink="true">https://forum.qt.io/post/466766</guid><dc:creator><![CDATA[haifisch]]></dc:creator><pubDate>Sat, 30 Jun 2018 22:11:57 GMT</pubDate></item><item><title><![CDATA[Reply to Why does not the icon appear on the button? on Sat, 30 Jun 2018 22:07:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> I do not have this. How do I configure this option?</p>
]]></description><link>https://forum.qt.io/post/466765</link><guid isPermaLink="true">https://forum.qt.io/post/466765</guid><dc:creator><![CDATA[haifisch]]></dc:creator><pubDate>Sat, 30 Jun 2018 22:07:54 GMT</pubDate></item><item><title><![CDATA[Reply to Why does not the icon appear on the button? on Sat, 30 Jun 2018 22:05:12 GMT]]></title><description><![CDATA[<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/605483c3-c4cd-4336-ba27-c0edf0107ed3.png" alt="0_1530396306930_c5534d8e-52e6-46b1-8fe0-3603d53e9fce-image.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/466764</link><guid isPermaLink="true">https://forum.qt.io/post/466764</guid><dc:creator><![CDATA[haifisch]]></dc:creator><pubDate>Sat, 30 Jun 2018 22:05:12 GMT</pubDate></item><item><title><![CDATA[Reply to Why does not the icon appear on the button? on Sat, 30 Jun 2018 21:53:34 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
If you go to resource file, find the icon and RIGHT click it.<br />
Does the path mathes the one in code ?</p>
<p dir="auto"><img src="http://imagizer.imageshack.com/img924/936/0tWPP6.png" alt="alt text" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.qt.io/post/466759</link><guid isPermaLink="true">https://forum.qt.io/post/466759</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 30 Jun 2018 21:53:34 GMT</pubDate></item></channel></rss>