<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python GUIs</title><link>https://www.pythonguis.com/</link><description>Create GUI applications with Python and Qt</description><atom:link href="https://www.pythonguis.com/feeds/rss.xml" rel="self"/><lastBuildDate>Wed, 04 Nov 2026 06:00:00 +0000</lastBuildDate><item><title>Change color in QProgressBar delegate — How to dynamically change QProgressBar colors in a QTableView delegate</title><link>https://www.pythonguis.com/faq/change-color-in-qprogressbar-delegate/</link><description>How can I change the color of a QProgressBar delegate in a QTableView when a process starts or stops? I'm using a delegate to show an indeterminate progress bar (with &lt;code&gt;setRange(0, 0)&lt;/code&gt;), and I want it to be green when running and red when stopped, but replacing the delegate doesn't seem to redraw the color.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 04 Nov 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-11-04:/faq/change-color-in-qprogressbar-delegate/</guid><category>pyside6</category><category>pyside</category><category>python</category><category>qtableview</category><category>delegate</category><category>qprogressbar</category><category>qt</category><category>qt6</category></item><item><title>Passing Arguments to Threaded Functions in PyQt6 — Understanding the difference between passing a function and calling a function when using QThreadPool and QRunnable</title><link>https://www.pythonguis.com/faq/delay-in-signal-from-thread/</link><description>I'm running a long-running function in a separate thread using &lt;code&gt;QThreadPool&lt;/code&gt; and a &lt;code&gt;QRunnable&lt;/code&gt; worker. When I pass the function without arguments, it runs correctly in the background. But when I try to pass arguments, the GUI freezes until the function finishes. What am I doing wrong?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 28 Oct 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-10-28:/faq/delay-in-signal-from-thread/</guid><category>pyqt6</category><category>pyqt</category><category>pyside6</category><category>pyside</category><category>threads</category><category>concurrency</category><category>python</category><category>qt</category><category>qt6</category><category>pyqt6-concurrency</category><category>pyside6-concurrency</category></item><item><title>Getting a Value from a Model Using Row-Column Indices — How to retrieve data from a Qt model using row and column integers</title><link>https://www.pythonguis.com/faq/get-value-from-model-through-pair-of-integers-representing-row-and-column/</link><description>How do I retrieve a value from a QAbstractTableModel using a pair of integers (row and column), for example when clicking a button, rather than clicking on a cell in a QTableView?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 28 Oct 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-10-28:/faq/get-value-from-model-through-pair-of-integers-representing-row-and-column/</guid><category>pyqt6</category><category>pyqt</category><category>modelview</category><category>qtableview</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Change the color of the ProgressBar indicator text when it exceeds 50%</title><link>https://www.pythonguis.com/faq/change-the-color-of-the-progressbar-indicator-text-when-it-exceeds-50/</link><description>How can I change the text color from black to white of the percentage indicator inside the &lt;code&gt;QProgressBar&lt;/code&gt; when it exceeds the value of 50?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 07 Oct 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-10-07:/faq/change-the-color-of-the-progressbar-indicator-text-when-it-exceeds-50/</guid><category>pyqt5</category><category>pyqt</category><category>qprogressbar</category><category>stylesheets</category><category>python</category><category>qt</category><category>qt5</category></item><item><title>Using Complex Data Sources with PyQt6 Model/View Architecture — How to use JSON, nested data, and other complex structures in your Qt table and list views</title><link>https://www.pythonguis.com/faq/complex-data-in-pyqt-models/</link><description>I have a complex data set in a JSON file. Is it possible to use this as my model's data in PyQt6 views, or do I need to simplify it to a basic table?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 07 Oct 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-10-07:/faq/complex-data-in-pyqt-models/</guid><category>pyqt6</category><category>python</category><category>model-view</category><category>qtableview</category><category>json</category><category>qt</category><category>qt6</category></item><item><title>Changing Ticks in PyQtGraph Objects to Strings — How to replace numeric axis ticks with custom labels like month names or dates in PyQtGraph</title><link>https://www.pythonguis.com/faq/changing-ticks-in-pyqtgraph-objects-to-strings/</link><description>How do I replace the numeric tick labels on a PyQtGraph axis with custom strings, like month names or category labels?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 30 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-30:/faq/changing-ticks-in-pyqtgraph-objects-to-strings/</guid><category>pyqt6</category><category>pyqt</category><category>pyqtgraph</category><category>plotting</category><category>python</category><category>qt</category><category>qt6</category><category>data-science</category><category>pyqt6-data-science</category></item><item><title>Dynamically Adding Rows of Widgets in PyQt6 — How to use QGridLayout to add multiple widgets per row at runtime</title><link>https://www.pythonguis.com/faq/creating-dynamic-textboxes/</link><description>I have a GUI where I dynamically add a QLineEdit for each image a user selects. That part works. But now I want to extend it so that each image gets a &lt;em&gt;row&lt;/em&gt; of three text boxes &amp;mdash; one for the filename, one for the width, and one for the height. How do I dynamically add multiple widgets horizontally for each new entry?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 23 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-23:/faq/creating-dynamic-textboxes/</guid><category>pyqt6</category><category>pyqt</category><category>layouts</category><category>widgets</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Clean up on exit — Stopping threads when closing a PyQt6 application — How to properly shut down background threads and workers when your application window is closed</title><link>https://www.pythonguis.com/faq/clean-up-on-exit-application/</link><description>I'm using QThreadPool and worker threads in my PyQt application. When I click the X button to close the window, the threads keep running in the background. What's the best way to clean everything up on application exit?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 09 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-09:/faq/clean-up-on-exit-application/</guid><category>pyqt6</category><category>python</category><category>threads</category><category>qthread</category><category>qt</category><category>qt6</category></item><item><title>Fixing Crashes When Using NumPy Arrays with QImage in Qt Threads — How to safely pass image data between threads when streaming video or updating displays</title><link>https://www.pythonguis.com/faq/crashing-in-qrunner-threads-with-numpy/</link><description>I'm using a threaded runner to stream a live video feed by converting a NumPy array to a &lt;code&gt;QImage&lt;/code&gt;, then to a &lt;code&gt;QPixmap&lt;/code&gt;, and displaying it on a &lt;code&gt;QLabel&lt;/code&gt;. But I'm frequently encountering crashes when the label is resized too quickly or the scroll area is scrolled. Could this be a problem with the &lt;code&gt;QImage&lt;/code&gt; memory buffer getting cleared before the &lt;code&gt;QPixmap&lt;/code&gt; can update? Is this fixable, or is it a fundamental issue with threads in Python/Qt?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 09 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-09:/faq/crashing-in-qrunner-threads-with-numpy/</guid><category>python</category><category>pyqg6</category><category>pyside6</category><category>threads</category><category>numpy</category><category>qimage</category><category>concurrency</category><category>qt</category><category>qt6</category><category>data-science</category><category>pyside6-data-science</category><category>pyside6-concurrency</category></item><item><title>How to Check if a QLineEdit is Empty in Python — Empty strings are falsey in Python</title><link>https://www.pythonguis.com/faq/check-qlineedit-empty-pyqt/</link><description>A reader asked:</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 09 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-09:/faq/check-qlineedit-empty-pyqt/</guid><category>qlineedit</category><category>widgets</category><category>pyqt</category><category>pyside</category><category>python</category><category>qt</category></item><item><title>Are there any built-in QIcons? — Using built-in icons for your apps.</title><link>https://www.pythonguis.com/faq/built-in-qicons-pyqt/</link><description>&lt;p&gt;In the tutorials on this site and in &lt;a href="/books/"&gt;my books&lt;/a&gt; I recommend using the &lt;a href="https://p.yusukekamiyamane.com/"&gt;fugue icons set&lt;/a&gt;. This is a &lt;em&gt;free&lt;/em&gt; set of icons from Yusuke Kamiyamane, a freelance designer from Tokyo. The set contains 3,570 icons and is a great way to add some nice visual touches to your application without much hassle.&lt;/p&gt;
&lt;p&gt;But this isn't the only icon set available, and there's another option you may not know about. Read on for details.&lt;/p&gt;
&lt;p&gt;Veronica asked:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Are there any built-in icons with PyQt5? I have searched the web and it seems like there are some but I can't find any examples of them being used. Does it depend on the situation? If so, then in which cases can I use an icon without downloading it first?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;First we need to clarify what is meant by &lt;em&gt;built-in&lt;/em&gt; icons &amp;mdash; it can mean two different things depending on context &amp;mdash; either Qt built-in, or system built-in (Linux only). I'll start with the Qt built-ins as that's cross-platform (they're available on Windows, macOS and Linux).&lt;/p&gt;
&lt;h2 id="qt-standard-icons-qstyle-standardpixmap"&gt;Qt Standard Icons (QStyle StandardPixmap)&lt;/h2&gt;
&lt;p&gt;Qt ships with a small set of standard icons you can use in any of your applications for common actions. These built-in icons are accessed through the &lt;code&gt;QStyle.StandardPixmap&lt;/code&gt; enum and retrieved using &lt;code&gt;style().standardIcon()&lt;/code&gt;. They're available on all platforms &amp;mdash; Windows, macOS, and Linux &amp;mdash; making them a convenient choice when you need common UI icons without bundling external assets.&lt;/p&gt;
&lt;p&gt;The following Python script displays all the built-in Qt standard icons in a grid layout:&lt;/p&gt;
&lt;div class="tabbed-area multicode"&gt;&lt;ul class="tabs"&gt;&lt;li class="tab-link current" data-tab="d8376068b4d64039b249b980b43fc6ad" v-on:click="switch_tab"&gt;PyQt5&lt;/li&gt;
&lt;li class="tab-link" data-tab="c23ef1e06dc740209a1a4a675b32c856" v-on:click="switch_tab"&gt;PyQt6&lt;/li&gt;
&lt;li class="tab-link" data-tab="5d50da83f3094c24aad9f3ed6b9e4a33" v-on:click="switch_tab"&gt;PySide2&lt;/li&gt;
&lt;li class="tab-link" data-tab="e032b106b56a4b42a56d693a96dcdefb" v-on:click="switch_tab"&gt;PySide6&lt;/li&gt;&lt;/ul&gt;&lt;div class="tab-content current code-block-outer" id="d8376068b4d64039b249b980b43fc6ad"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys

from PyQt5.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget


class Window(QWidget):
    def __init__(self):
        super().__init__()

        icons = sorted([attr for attr in dir(QStyle) if attr.startswith("SP_")])
        layout = QGridLayout()

        for n, name in enumerate(icons):
            btn = QPushButton(name)

            pixmapi = getattr(QStyle, name)
            icon = self.style().standardIcon(pixmapi)
            btn.setIcon(icon)
            layout.addWidget(btn, n // 4, n % 4)

        self.setLayout(layout)


app = QApplication(sys.argv)

w = Window()
w.show()

app.exec_()


&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="tab-content code-block-outer" id="c23ef1e06dc740209a1a4a675b32c856"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys

from PyQt6.QtWidgets import (QApplication, QGridLayout, QPushButton, QStyle,
                             QWidget)


class Window(QWidget):
    def __init__(self):
        super().__init__()

        icons = sorted([attr for attr in dir(QStyle.StandardPixmap) if attr.startswith("SP_")])
        layout = QGridLayout()

        for n, name in enumerate(icons):
            btn = QPushButton(name)

            pixmapi = getattr(QStyle.StandardPixmap, name)
            icon = self.style().standardIcon(pixmapi)
            btn.setIcon(icon)
            layout.addWidget(btn, int(n/4), int(n%4))

        self.setLayout(layout)


app = QApplication(sys.argv)

w = Window()
w.show()

app.exec()

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="tab-content code-block-outer" id="5d50da83f3094c24aad9f3ed6b9e4a33"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys

from PySide2.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget


class Window(QWidget):
    def __init__(self):
        super().__init__()

        icons = sorted([attr for attr in dir(QStyle) if attr.startswith("SP_")])
        layout = QGridLayout()

        for n, name in enumerate(icons):
            btn = QPushButton(name)

            pixmapi = getattr(QStyle, name)
            icon = self.style().standardIcon(pixmapi)
            btn.setIcon(icon)
            layout.addWidget(btn, n // 4, n % 4)

        self.setLayout(layout)


app = QApplication(sys.argv)

w = Window()
w.show()

app.exec_()

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="tab-content code-block-outer" id="e032b106b56a4b42a56d693a96dcdefb"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys

from PySide6.QtWidgets import QApplication, QGridLayout, QPushButton, QStyle, QWidget


class Window(QWidget):
    def __init__(self):
        super().__init__()

        icons = sorted(
            [attr for attr in dir(QStyle.StandardPixmap) if attr.startswith("SP_")]
        )
        layout = QGridLayout()

        for n, name in enumerate(icons):
            btn = QPushButton(name)

            pixmapi = getattr(QStyle, name)
            icon = self.style().standardIcon(pixmapi)
            btn.setIcon(icon)
            layout.addWidget(btn, n // 4, n % 4)

        self.setLayout(layout)


app = QApplication(sys.argv)

w = Window()
w.show()

app.exec()

&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you run this script you'll see the following window, listing all the available built-in Qt icons.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Qt's Built-in Standard Icons displayed in a grid using QStyle StandardPixmap" src="{static}icons-builtin.png" srcset="https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icons-builtin.png?tr=w-100 100w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icons-builtin.png?tr=w-200 200w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icons-builtin.png?tr=w-400 400w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icons-builtin.png?tr=w-600 600w" loading="lazy" width="900" height="706"/&gt;
&lt;em&gt;Qt's Built-in Icons &amp;mdash; all QStyle.StandardPixmap icons shown with their names&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="complete-list-of-qt-built-in-standard-icons-qstylestandardpixmap"&gt;Complete List of Qt Built-in Standard Icons (QStyle.StandardPixmap)&lt;/h2&gt;
&lt;p&gt;The full table of all &lt;code&gt;QStyle.StandardPixmap&lt;/code&gt; icon names is below. You can use any of these in PyQt5, PyQt6, PySide2, or PySide6 applications.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;..&lt;/th&gt;
&lt;th&gt;..&lt;/th&gt;
&lt;th&gt;..&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowBack&lt;/td&gt;
&lt;td&gt;SP_DirIcon&lt;/td&gt;
&lt;td&gt;SP_MediaSkipBackward&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowDown&lt;/td&gt;
&lt;td&gt;SP_DirLinkIcon&lt;/td&gt;
&lt;td&gt;SP_MediaSkipForward&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowForward&lt;/td&gt;
&lt;td&gt;SP_DirOpenIcon&lt;/td&gt;
&lt;td&gt;SP_MediaStop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowLeft&lt;/td&gt;
&lt;td&gt;SP_DockWidgetCloseButton&lt;/td&gt;
&lt;td&gt;SP_MediaVolume&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowRight&lt;/td&gt;
&lt;td&gt;SP_DriveCDIcon&lt;/td&gt;
&lt;td&gt;SP_MediaVolumeMuted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ArrowUp&lt;/td&gt;
&lt;td&gt;SP_DriveDVDIcon&lt;/td&gt;
&lt;td&gt;SP_MessageBoxCritical&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_BrowserReload&lt;/td&gt;
&lt;td&gt;SP_DriveFDIcon&lt;/td&gt;
&lt;td&gt;SP_MessageBoxInformation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_BrowserStop&lt;/td&gt;
&lt;td&gt;SP_DriveHDIcon&lt;/td&gt;
&lt;td&gt;SP_MessageBoxQuestion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_CommandLink&lt;/td&gt;
&lt;td&gt;SP_DriveNetIcon&lt;/td&gt;
&lt;td&gt;SP_MessageBoxWarning&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_ComputerIcon&lt;/td&gt;
&lt;td&gt;SP_FileDialogBack&lt;/td&gt;
&lt;td&gt;SP_TitleBarCloseButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_CustomBase&lt;/td&gt;
&lt;td&gt;SP_FileDialogContentsView&lt;/td&gt;
&lt;td&gt;SP_TitleBarContextHelpButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DesktopIcon&lt;/td&gt;
&lt;td&gt;SP_FileDialogDetailedView&lt;/td&gt;
&lt;td&gt;SP_TitleBarMaxButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogApplyButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogEnd&lt;/td&gt;
&lt;td&gt;SP_TitleBarMenuButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogCancelButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogInfoView&lt;/td&gt;
&lt;td&gt;SP_TitleBarMinButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogCloseButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogListView&lt;/td&gt;
&lt;td&gt;SP_TitleBarNormalButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogDiscardButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogNewFolder&lt;/td&gt;
&lt;td&gt;SP_TitleBarShadeButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogHelpButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogStart&lt;/td&gt;
&lt;td&gt;SP_TitleBarUnshadeButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogNoButton&lt;/td&gt;
&lt;td&gt;SP_FileDialogToParent&lt;/td&gt;
&lt;td&gt;SP_ToolBarHorizontalExtensionButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogOkButton&lt;/td&gt;
&lt;td&gt;SP_FileIcon&lt;/td&gt;
&lt;td&gt;SP_ToolBarVerticalExtensionButton&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogResetButton&lt;/td&gt;
&lt;td&gt;SP_FileLinkIcon&lt;/td&gt;
&lt;td&gt;SP_TrashIcon&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogSaveButton&lt;/td&gt;
&lt;td&gt;SP_MediaPause&lt;/td&gt;
&lt;td&gt;SP_VistaShield&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DialogYesButton&lt;/td&gt;
&lt;td&gt;SP_MediaPlay&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DirClosedIcon&lt;/td&gt;
&lt;td&gt;SP_MediaSeekBackward&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;SP_DirHomeIcon&lt;/td&gt;
&lt;td&gt;SP_MediaSeekForward&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="how-to-use-a-specific-built-in-qicon-in-your-application"&gt;How to Use a Specific Built-in QIcon in Your Application&lt;/h2&gt;
&lt;p&gt;In our script above to get the icons we're looking them up by name on the &lt;code&gt;QStyle&lt;/code&gt; object, using &lt;code&gt;getattr&lt;/code&gt; &amp;mdash; but this is only necessary so we can iterate over the list of names and display the icon next to their name. If you want a specific icon you can access it directly. For example, to use the critical message box icon:&lt;/p&gt;
&lt;div class="tabbed-area multicode"&gt;&lt;ul class="tabs"&gt;&lt;li class="tab-link current" data-tab="664f7945a6c5433abbe2fd7ee4909f7f" v-on:click="switch_tab"&gt;Others&lt;/li&gt;
&lt;li class="tab-link" data-tab="639b1511df5a4cc1ba816a3c18777999" v-on:click="switch_tab"&gt;PyQt6&lt;/li&gt;&lt;/ul&gt;&lt;div class="tab-content current code-block-outer" id="664f7945a6c5433abbe2fd7ee4909f7f"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;pixmapi = QStyle.SP_MessageBoxCritical
icon = self.style().standardIcon(pixmapi)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="tab-content code-block-outer" id="639b1511df5a4cc1ba816a3c18777999"&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;pixmapi = QStyle.StandardPixmap.SP_MessageBoxCritical
icon = self.style().standardIcon(pixmapi)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p class="admonition admonition-note"&gt;&lt;span class="admonition-kind"&gt;&lt;i class="fas fa-sticky-note"&gt;&lt;/i&gt;&lt;/span&gt;  In PyQt6 the flags must be accessed via &lt;code&gt;QStyle.StandardPixmap&lt;/code&gt;. In other versions, they are available on &lt;code&gt;QStyle&lt;/code&gt; itself.&lt;/p&gt;
&lt;p&gt;Once you have the &lt;code&gt;QIcon&lt;/code&gt; object, you can use it anywhere Qt expects an icon &amp;mdash; on buttons, toolbars, menus, window titles, and more.&lt;/p&gt;
&lt;h2 id="free-desktop-theme-icons-linux"&gt;Free Desktop Theme Icons (Linux)&lt;/h2&gt;
&lt;p&gt;On Linux desktops there is something called the &lt;em&gt;Free Desktop Specification&lt;/em&gt; which defines standard names for icons for specific actions.&lt;/p&gt;
&lt;p&gt;If your application uses these specific icon names (and loads the icon from a "theme") then on Linux your application will use the current icon set which is enabled on the desktop. The idea is to make all applications have the same look &amp;amp; feel while remaining user configurable.&lt;/p&gt;
&lt;h3&gt;Setting Theme Icons in Qt Designer&lt;/h3&gt;
&lt;p&gt;To use Free Desktop theme icons within Qt Designer you would select the drop-down and choose "Set Icon From Theme..."&lt;/p&gt;
&lt;p&gt;&lt;img alt="Setting an icon from theme in Qt Designer" src="{static}icontheme1.png" srcset="https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme1.png?tr=w-100 100w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme1.png?tr=w-200 200w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme1.png?tr=w-400 400w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme1.png?tr=w-600 600w" loading="lazy" width="972" height="194"/&gt;&lt;/p&gt;
&lt;p&gt;You then enter the &lt;em&gt;name&lt;/em&gt; of the icon you want to use, e.g. &lt;code&gt;document-new&lt;/code&gt; (the &lt;a href="https://specifications.freedesktop.org/icon-naming-spec/latest/ar01s04.html"&gt;full list of valid names&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Entering icon theme name in Qt Designer" src="{static}icontheme2.png" srcset="https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme2.png?tr=w-100 100w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme2.png?tr=w-200 200w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme2.png?tr=w-400 400w, https://ik.imagekit.io/mfitzp/pythonguis/static/faq/built-in-qicons-pyqt/icontheme2.png?tr=w-600 600w" loading="lazy" width="972" height="194"/&gt;&lt;/p&gt;
&lt;h3&gt;Setting Theme Icons in Python Code with QIcon.fromTheme()&lt;/h3&gt;
&lt;p&gt;If you're not using Qt Designer, you can set icons from a theme in your Python code using &lt;code&gt;QIcon.fromTheme()&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;        icon = QtGui.QIcon.fromTheme("document-new")
        self.pushButton_n6.setIcon(icon)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;If you're developing a cross-platform Python GUI application you'll still need your own icons for Windows &amp;amp; macOS, but by using these theme names you can ensure that your app looks &lt;em&gt;native&lt;/em&gt; when run on Linux.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Does the &lt;code&gt;QIcon.fromTheme()&lt;/code&gt; method only work on Linux?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Qt themes work on all platforms, it's just that on Linux you get the theme for &lt;em&gt;free&lt;/em&gt;. On non-Linux platforms you have to define your own icon theme from scratch. However, this is only really worth doing if you want to have a Linux-native look &amp;mdash; for other use cases the &lt;code&gt;QResource&lt;/code&gt; system is simpler.&lt;/p&gt;
&lt;h2 id="summary"&gt;Summary&lt;/h2&gt;
&lt;p&gt;There are two ways to use built-in icons in your PyQt or PySide applications without downloading external icon sets:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Qt Standard Icons (QStyle.StandardPixmap)&lt;/strong&gt; &amp;mdash; A cross-platform set of common UI icons built into Qt itself, accessible via &lt;code&gt;style().standardIcon()&lt;/code&gt;. These work on Windows, macOS, and Linux.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Free Desktop Theme Icons&lt;/strong&gt; &amp;mdash; Linux-specific system icons accessed via &lt;code&gt;QIcon.fromTheme()&lt;/code&gt; that match the user's current desktop theme for a native look and feel.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For most cross-platform PyQt6 or PySide6 projects, bundling a dedicated icon set like Fugue gives you the most control over your app's appearance. But for quick prototypes or platform-specific tools, Qt's built-in icons are a convenient and dependency-free option.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 02 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-02:/faq/built-in-qicons-pyqt/</guid><category>pyqt</category><category>pyqt6</category><category>pyside</category><category>pyside6</category><category>icons</category><category>theme</category><category>qt-designer</category><category>qstyle</category><category>qicon</category><category>python</category><category>qt</category><category>qt6</category><category>pyqt6-qt-designer</category><category>pyside6-qt-designer</category></item><item><title>Understanding QPainter Coordinates in PyQt6 — How the coordinate system works for drawing on canvases in PyQt6</title><link>https://www.pythonguis.com/faq/coordinates-on-qpainter/</link><description>I really having trouble understanding the coordinate system used in &lt;code&gt;QPainter&lt;/code&gt;. Can you explain how this works?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 02 Sep 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-09-02:/faq/coordinates-on-qpainter/</guid><category>pyqt6</category><category>pyqt</category><category>python</category><category>qpainter</category><category>drawing</category><category>coordinates</category><category>qt</category><category>qt6</category></item><item><title>Creating PySide6 UI without .ui / Qt Designer — Build your entire GUI in pure Python code, no .ui files required</title><link>https://www.pythonguis.com/faq/creating-pyside2-ui-without-ui-qt-designer/</link><description>Is it possible to write a PySide6 application without using .ui files or Qt Designer? How can I create widgets and lay out a window entirely in Python code?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 19 Aug 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-08-19:/faq/creating-pyside2-ui-without-ui-qt-designer/</guid><category>pyside6</category><category>pyside</category><category>python</category><category>gui</category><category>qt</category><category>qt6</category></item><item><title>Adding QTabWidget to a Layout Alongside Other Widgets in PyQt6 — How to combine QTabWidget with other layouts without it taking over your entire window</title><link>https://www.pythonguis.com/faq/cant-integrate-qtabwidget-into-a-layout/</link><description>I'm trying to create a layout in PyQt and implement different layouts into one QHBoxLayout. Everything works fine, but when I add a QTabWidget alongside other layouts, it becomes the only visible widget &amp;mdash; as if everything else disappears. Isn't it possible to have a QTabWidget in a layout beside other layouts?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 12 Aug 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-08-12:/faq/cant-integrate-qtabwidget-into-a-layout/</guid><category>pyqt6</category><category>layout</category><category>qtabwidget</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Handling Image Drag and Drop from Web Browsers in PyQt6 — Why toLocalFile() returns an empty string and how to handle remote image drops correctly</title><link>https://www.pythonguis.com/faq/dragging-and-dropping-in-rich-text-example-app/</link><description>When dragging and dropping images from a web browser into a PyQt6 rich text editor, &lt;code&gt;toLocalFile()&lt;/code&gt; sometimes returns a blank string. It works for some images (like Google image search results) but fails for others (like images embedded directly on a webpage). Why does this happen, and how can I handle it?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 05 Aug 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-08-05:/faq/dragging-and-dropping-in-rich-text-example-app/</guid><category>pyqt6</category><category>pyqt</category><category>drag-and-drop</category><category>rich-text</category><category>python</category><category>mime-data</category><category>qt</category><category>qt6</category></item><item><title>Constantly Print Subprocess Output While Process is Running — How to stream live output from a subprocess into your PyQt6 GUI without freezing the interface</title><link>https://www.pythonguis.com/faq/constantly-print-subprocess-output-while-process-is-running/</link><description>I need to call a legacy Bash program and display the results in a Qt window. The problem is the subprocess doesn't return each output line as it happens &amp;mdash; it waits until the entire command is finished, then dumps everything to the window at once. If the command takes a long time, the user thinks the system is frozen. How can I get live, line-by-line output from a subprocess into my Qt application?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 22 Jul 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-07-22:/faq/constantly-print-subprocess-output-while-process-is-running/</guid><category>pyqt6</category><category>python</category><category>subprocess</category><category>qprocess</category><category>qthread</category><category>gui</category><category>qt</category><category>qt6</category></item><item><title>Why Widgets Appear as Separate Windows — Understanding widget parenting in Qt and how to fix widgets that float outside your main window</title><link>https://www.pythonguis.com/faq/adding-new-tabs-in-tabwidget-appears-as-a-seperate-window-when-tab-is-selected/</link><description>Sometimes when I dynamically add widgets to tabs in my PyQt6 application, they pop out as windows instead. What's going on?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 08 Jul 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-07-08:/faq/adding-new-tabs-in-tabwidget-appears-as-a-seperate-window-when-tab-is-selected/</guid><category>pyqt6</category><category>pyqt</category><category>widgets</category><category>troubleshooting</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>How to Set Row Background Colors in a QTableView — Use Qt's BackgroundRole to color entire rows based on your data</title><link>https://www.pythonguis.com/faq/backgroundcolor-for-row-in-qtableview/</link><description>I have a QTableView table showing some data about connected devices. How can I highlight rows to give a visual indicator of the current status of the device?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 10 Jun 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-06-10:/faq/backgroundcolor-for-row-in-qtableview/</guid><category>pyqt6</category><category>pyqt</category><category>qtableview</category><category>model-view</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Authentication and Authorization with PyQt6 or PySide6 — Secure your desktop applications with login flows, token-based auth, and role-based access control</title><link>https://www.pythonguis.com/faq/authentication-and-authorization-with-pyqt6-or-pyside6/</link><description>How can I add authentication and authorization to a PyQt6 application? Is there something built into Qt to make this easier?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 03 Jun 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-06-03:/faq/authentication-and-authorization-with-pyqt6-or-pyside6/</guid><category>pyqt6</category><category>pyqt</category><category>pyside6</category><category>pyside</category><category>authentication</category><category>authorization</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Fixing Missing Icons in PyInstaller-Packaged PyQt6 Applications on Windows — Why your app icon disappears after packaging and how to fix it</title><link>https://www.pythonguis.com/faq/always-the-default-icon/</link><description>I've packaged my PyQt application with PyInstaller, but the icon isn't showing up &amp;mdash; both the executable icon and the running application icon are just the default Python/Windows icon. What's going on?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 27 May 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-05-27:/faq/always-the-default-icon/</guid><category>pyqt6</category><category>pyinstaller</category><category>windows</category><category>icons</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>Adding QComboBox to a QTableView and getting/setting values after creation — Use QItemDelegate to embed combo boxes in your table views, with per-row data and value tracking</title><link>https://www.pythonguis.com/faq/adding-qcombobox-to-a-qtableview-and-getting-setting-values-after-creation/</link><description>I'm using a QTableView to display data, and would like to limit the choices in some of the fields using a drop-down. I can use &lt;code&gt;QComboBox&lt;/code&gt; to provide a list of choices in a normal UI, but how can I do that in a table view?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 20 May 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-05-20:/faq/adding-qcombobox-to-a-qtableview-and-getting-setting-values-after-creation/</guid><category>pyqt6</category><category>pyqt</category><category>qtableview</category><category>qcombobox</category><category>delegate</category><category>model-view</category><category>python</category><category>qt</category><category>qt6</category></item><item><title>How to Add Custom Widgets to Qt Designer — Use widget promotion to integrate your own Python widgets into Qt Designer layouts</title><link>https://www.pythonguis.com/faq/add-widgets-in-a-kind-of-library-show-in-the-qt-designer/</link><description>Can I use custom widgets in Qt Designer?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 13 May 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-05-13:/faq/add-widgets-in-a-kind-of-library-show-in-the-qt-designer/</guid><category>pyqt6</category><category>pyqt</category><category>qtdesigner</category><category>custom-widgets</category><category>widget-promotion</category><category>python</category><category>qt</category><category>qt6</category><category>pyqt6-custom-widgets</category></item><item><title>Sorting and Filtering a QTableView with QSortFilterProxyModel — Learn how to add interactive sorting and filtering to your PyQt/PySide table views without touching your underlying data</title><link>https://www.pythonguis.com/faq/add-some-explanation-on-sorting-a-qtableview/</link><description>&lt;blockquote&gt;
&lt;p&gt;I'm using QTableView to show some data, which works well. But I would like to be able to sort the data by different columns. How can I do this without sorting the data manually?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you've already built a &lt;code&gt;QTableView&lt;/code&gt; with a custom model, you might be wondering how to let users sort columns by clicking headers or filter rows based on search input. The good news is that Qt provides a ready-made tool for this: &lt;code&gt;QSortFilterProxyModel&lt;/code&gt;. It sits between your model and your view, rearranging and filtering the data &lt;em&gt;without modifying the original source&lt;/em&gt;. Your data stays untouched &amp;mdash; the proxy just changes how it's presented.&lt;/p&gt;
&lt;p&gt;In this tutorial, we'll start with a simple table model and progressively add sorting, filtering, and then tackle some of the common pitfalls &amp;mdash; like working with proxy indexes correctly and avoiding crashes when updating data.&lt;/p&gt;
&lt;h2 id="a-simple-table-model"&gt;A Simple Table Model&lt;/h2&gt;
&lt;p&gt;Let's begin with a basic &lt;code&gt;QTableView&lt;/code&gt; displaying a list-of-lists. This is the same pattern used in the &lt;a href="https://www.pythonguis.com/tutorials/pyqt6-modelview-architecture/"&gt;model/view architecture tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys
from PyQt6.QtCore import Qt, QAbstractTableModel
from PyQt6.QtWidgets import QApplication, QMainWindow, QTableView


class TableModel(QAbstractTableModel):
    def __init__(self, data):
        super().__init__()
        self._data = data
        self._headers = ["Name", "Age", "City"]

    def data(self, index, role):
        if role == Qt.ItemDataRole.DisplayRole:
            return self._data[index.row()][index.column()]

    def rowCount(self, index):
        return len(self._data)

    def columnCount(self, index):
        return len(self._data[0])

    def headerData(self, section, orientation, role):
        if role == Qt.ItemDataRole.DisplayRole:
            if orientation == Qt.Orientation.Horizontal:
                return self._headers[section]


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.table = QTableView()

        data = [
            ["Alice", 25, "New York"],
            ["Bob", 30, "Denver"],
            ["Charlie", 35, "Austin"],
            ["Diana", 28, "Denver"],
            ["Eve", 22, "Austin"],
        ]

        self.model = TableModel(data)
        self.table.setModel(self.model)

        self.setCentralWidget(self.table)
        self.setWindowTitle("QTableView &amp;mdash; No Sorting Yet")
        self.resize(500, 300)


app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Run this and you'll see a plain table. Clicking the column headers does nothing as sorting is off by default. Let's change that first.&lt;/p&gt;
&lt;h2 id="adding-sorting-with-qsortfilterproxymodel"&gt;Adding sorting with QSortFilterProxyModel&lt;/h2&gt;
&lt;p&gt;To add sorting, we insert a &lt;code&gt;QSortFilterProxyModel&lt;/code&gt; between our &lt;code&gt;TableModel&lt;/code&gt; and the &lt;code&gt;QTableView&lt;/code&gt;. The proxy model wraps the source model and provides sorted (and later, filtered) access to the same data.&lt;/p&gt;
&lt;p&gt;Here's what changes in the &lt;code&gt;MainWindow.__init__&lt;/code&gt; method:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;from PyQt6.QtCore import Qt, QAbstractTableModel, QSortFilterProxyModel

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.table = QTableView()

        data = [
            ["Alice", 25, "New York"],
            ["Bob", 30, "Denver"],
            ["Charlie", 35, "Austin"],
            ["Diana", 28, "Denver"],
            ["Eve", 22, "Austin"],
        ]

        self.model = TableModel(data)

        self.proxy_model = QSortFilterProxyModel()
        self.proxy_model.setSourceModel(self.model)

        self.table.setModel(self.proxy_model)
        self.table.setSortingEnabled(True)

        self.setCentralWidget(self.table)
        self.setWindowTitle("QTableView &amp;mdash; Sortable!")
        self.resize(500, 300)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;We've added the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create the &lt;code&gt;QSortFilterProxyModel&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Tell it which source model to wrap with &lt;code&gt;setSourceModel()&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Give the &lt;em&gt;proxy&lt;/em&gt; model to the view (not the source model), and call &lt;code&gt;setSortingEnabled(True)&lt;/code&gt; on the view.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now when you click a column header, the rows reorder. Click again to reverse the sort direction. The little arrow indicator on the header shows you which column is currently sorted and in which direction.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Sortable QTableView with proxy model &amp;mdash; clicking headers sorts the data." src="sortable-table.png"/&gt;&lt;/p&gt;
&lt;p&gt;Notice that the underlying &lt;code&gt;data&lt;/code&gt; list hasn't changed at all. The proxy model handles everything by remapping indexes.&lt;/p&gt;
&lt;h2 id="adding-filtering"&gt;Adding filtering&lt;/h2&gt;
&lt;p&gt;Filtering works through the same proxy model. You tell the proxy which column to look at and what pattern to match, and it hides rows that don't match.&lt;/p&gt;
&lt;p&gt;Let's add a &lt;code&gt;QLineEdit&lt;/code&gt; that filters rows as you type. We'll filter on the "City" column (column index 2). If you're interested in a more complete search bar implementation, see the &lt;a href="https://www.pythonguis.com/tutorials/pyqt6-widget-search-bar/"&gt;widget search bar tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys
from PyQt6.QtCore import Qt, QAbstractTableModel, QSortFilterProxyModel
from PyQt6.QtWidgets import (
    QApplication, QMainWindow, QTableView,
    QVBoxLayout, QWidget, QLineEdit, QLabel,
)


class TableModel(QAbstractTableModel):
    def __init__(self, data):
        super().__init__()
        self._data = data
        self._headers = ["Name", "Age", "City"]

    def data(self, index, role):
        if role == Qt.ItemDataRole.DisplayRole:
            return self._data[index.row()][index.column()]

    def rowCount(self, index):
        return len(self._data)

    def columnCount(self, index):
        return len(self._data[0])

    def headerData(self, section, orientation, role):
        if role == Qt.ItemDataRole.DisplayRole:
            if orientation == Qt.Orientation.Horizontal:
                return self._headers[section]


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        data = [
            ["Alice", 25, "New York"],
            ["Bob", 30, "Denver"],
            ["Charlie", 35, "Austin"],
            ["Diana", 28, "Denver"],
            ["Eve", 22, "Austin"],
        ]

        self.model = TableModel(data)

        self.proxy_model = QSortFilterProxyModel()
        self.proxy_model.setSourceModel(self.model)
        self.proxy_model.setFilterCaseSensitivity(
            Qt.CaseSensitivity.CaseInsensitive
        )
        self.proxy_model.setFilterKeyColumn(2)  # Filter on "City" column

        self.table = QTableView()
        self.table.setModel(self.proxy_model)
        self.table.setSortingEnabled(True)

        self.search_input = QLineEdit()
        self.search_input.setPlaceholderText("Filter by city...")
        self.search_input.textChanged.connect(
            self.proxy_model.setFilterFixedString
        )

        layout = QVBoxLayout()
        layout.addWidget(QLabel("Search:"))
        layout.addWidget(self.search_input)
        layout.addWidget(self.table)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)
        self.setWindowTitle("QTableView &amp;mdash; Sort &amp;amp; Filter")
        self.resize(500, 400)


app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Type "Denver" into the search box and the table instantly filters to show only the rows where the City column matches. Type "aus" and you'll see the Austin rows (because we set case-insensitive matching).&lt;/p&gt;
&lt;p&gt;&lt;img alt="Filtering the table by typing in the search box &amp;mdash; only matching rows are shown." src="filter-table.png"/&gt;&lt;/p&gt;
&lt;p&gt;Let's recap what's happening:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;setFilterKeyColumn(2)&lt;/code&gt; tells the proxy to check column 2 ("City") when deciding which rows to show.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;setFilterFixedString&lt;/code&gt; performs a plain substring match. If the filter string appears anywhere in the cell value, the row is shown.&lt;/li&gt;
&lt;li&gt;We connected the &lt;code&gt;textChanged&lt;/code&gt; signal from the &lt;code&gt;QLineEdit&lt;/code&gt; directly to &lt;code&gt;setFilterFixedString&lt;/code&gt; on the proxy model. Every time the user types, the filter updates automatically.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Filtering across all columns&lt;/h3&gt;
&lt;p&gt;If you want to search across every column instead of just one, set the filter key column to &lt;code&gt;-1&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;self.proxy_model.setFilterKeyColumn(-1)  # Search all columns
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Now typing "25" will match Alice's row (age 25), and typing "Den" will still match the Denver rows.&lt;/p&gt;
&lt;h3&gt;Other filter modes&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;setFilterFixedString&lt;/code&gt; is the simplest option &amp;mdash; it does a plain text substring match. The proxy model also supports more powerful matching:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Wildcard matching&lt;/strong&gt; using &lt;code&gt;setFilterWildcard()&lt;/code&gt; &amp;mdash; supports &lt;code&gt;*&lt;/code&gt; and &lt;code&gt;?&lt;/code&gt; patterns, like &lt;code&gt;"D*ver"&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Regular expression matching&lt;/strong&gt; using &lt;code&gt;setFilterRegularExpression()&lt;/code&gt; &amp;mdash; supports full regex patterns for complex matching needs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For most interactive search boxes, &lt;code&gt;setFilterFixedString&lt;/code&gt; with case-insensitive matching is exactly what you need.&lt;/p&gt;
&lt;h2 id="working-with-proxy-indexes-correctly"&gt;Working with proxy indexes correctly&lt;/h2&gt;
&lt;p&gt;When a proxy model is active, the indexes your view reports are &lt;em&gt;proxy&lt;/em&gt; indexes, not source model indexes. If you click on a row in the filtered/sorted view, the &lt;code&gt;QModelIndex&lt;/code&gt; you receive refers to the &lt;em&gt;proxy model's&lt;/em&gt; row numbering, which may not match the original data.&lt;/p&gt;
&lt;p&gt;This matters when you need to do something with the underlying data &amp;mdash; like reading values from the source model or modifying a specific row.&lt;/p&gt;
&lt;p&gt;Consider this slot connected to the table's &lt;code&gt;clicked&lt;/code&gt; signal:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;self.table.clicked.connect(self.cell_clicked)

def cell_clicked(self, proxy_index):
    # This gives the row number in the proxy (filtered/sorted) view
    print(f"Proxy row: {proxy_index.row()}, column: {proxy_index.column()}")

    # To get the corresponding row in the SOURCE model:
    source_index = self.proxy_model.mapToSource(proxy_index)
    print(f"Source row: {source_index.row()}, column: {source_index.column()}")
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The method &lt;code&gt;mapToSource()&lt;/code&gt; translates a proxy index back to the source model's coordinate system. There's also &lt;code&gt;mapFromSource()&lt;/code&gt; for going the other direction &amp;mdash; converting a source index into the proxy's index, which is useful if you need to select or highlight a specific row in the view programmatically.&lt;/p&gt;
&lt;p&gt;If you forget this step and pass proxy indexes directly to your source model, you'll end up reading or modifying the wrong row. When filtering is active, the mismatch becomes obvious because the proxy's row 0 might correspond to row 3 in the source.&lt;/p&gt;
&lt;h3&gt;Reading data through the proxy&lt;/h3&gt;
&lt;p&gt;When you want to read data from a clicked row, you have two options:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;def cell_clicked(self, proxy_index):
    row = proxy_index.row()

    # Option 1: Read through the proxy model (uses proxy indexes)
    name = self.proxy_model.data(
        self.proxy_model.index(row, 0),
        Qt.ItemDataRole.DisplayRole,
    )

    # Option 2: Map to source and read from source model
    source_index = self.proxy_model.mapToSource(proxy_index)
    name = self.model.data(
        self.model.index(source_index.row(), 0),
        Qt.ItemDataRole.DisplayRole,
    )

    print(f"Clicked on: {name}")
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Both options give you the same result. Option 1 is often simpler since you're already working with proxy indexes from the view. Option 2 is necessary when you need to interact directly with the source model &amp;mdash; for example, to modify data or get the "real" row position in your data structure.&lt;/p&gt;
&lt;h2 id="avoiding-crashes-when-updating-the-source-model"&gt;Avoiding crashes when updating the source model&lt;/h2&gt;
&lt;p&gt;If you're updating the source model's data while a proxy model and view are connected, you need to properly notify Qt's model/view framework about the changes. Without these notifications, you can get segmentation faults or corrupted displays.&lt;/p&gt;
&lt;p&gt;The pattern for updating data looks like this inside your &lt;code&gt;QAbstractTableModel&lt;/code&gt; subclass:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;def update_data(self, new_data):
    self.layoutAboutToBeChanged.emit()
    self._data = new_data
    self.layoutChanged.emit()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;The &lt;code&gt;layoutAboutToBeChanged&lt;/code&gt; signal tells the proxy model (and the view) that the structure of the data is about to change. After you've made your changes, &lt;code&gt;layoutChanged&lt;/code&gt; tells everything to refresh. Skipping the &lt;code&gt;layoutAboutToBeChanged&lt;/code&gt; signal is a common cause of crashes &amp;mdash; the proxy model needs that heads-up to properly invalidate its internal mapping of indexes.&lt;/p&gt;
&lt;p&gt;For smaller changes, like updating a single cell, you can use &lt;code&gt;dataChanged&lt;/code&gt; instead:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;def set_value(self, row, col, value):
    self._data[row][col] = value
    index = self.index(row, col)
    self.dataChanged.emit(index, index)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;And if you're adding or removing rows, use &lt;code&gt;beginInsertRows&lt;/code&gt;/&lt;code&gt;endInsertRows&lt;/code&gt; or &lt;code&gt;beginRemoveRows&lt;/code&gt;/&lt;code&gt;endRemoveRows&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;def add_row(self, row_data):
    row_position = len(self._data)
    self.beginInsertRows(self.index(row_position, 0).parent(), row_position, row_position)
    self._data.append(row_data)
    self.endInsertRows()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Getting these signals right is what keeps the proxy model, the view, and your data all in sync.&lt;/p&gt;
&lt;h2 id="custom-sorting-behavior"&gt;Custom sorting behavior&lt;/h2&gt;
&lt;p&gt;The default sorting provided by &lt;code&gt;QSortFilterProxyModel&lt;/code&gt; uses &lt;code&gt;Qt.ItemDataRole.DisplayRole&lt;/code&gt; and works well for simple string and number comparisons. But sometimes you need more control &amp;mdash; for example, sorting a column of dates that are stored as strings, or sorting with a custom priority order.&lt;/p&gt;
&lt;p&gt;To customize sorting, subclass &lt;code&gt;QSortFilterProxyModel&lt;/code&gt; and override the &lt;code&gt;lessThan&lt;/code&gt; method. This method receives two &lt;code&gt;QModelIndex&lt;/code&gt; objects (from the source model) and should return &lt;code&gt;True&lt;/code&gt; if the left value should come before the right value.&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;class CustomProxyModel(QSortFilterProxyModel):
    def lessThan(self, left, right):
        left_data = self.sourceModel().data(left, Qt.ItemDataRole.DisplayRole)
        right_data = self.sourceModel().data(right, Qt.ItemDataRole.DisplayRole)

        # Example: sort numerically if both values are numbers
        try:
            return float(left_data) &amp;lt; float(right_data)
        except (ValueError, TypeError):
            # Fall back to string comparison
            return str(left_data).lower() &amp;lt; str(right_data).lower()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;Then use &lt;code&gt;CustomProxyModel&lt;/code&gt; instead of &lt;code&gt;QSortFilterProxyModel&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;self.proxy_model = CustomProxyModel()
self.proxy_model.setSourceModel(self.model)
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;This is useful when your table has mixed data types or when the display representation doesn't sort the way you'd expect (like date strings in "MM/DD/YYYY" format).&lt;/p&gt;
&lt;h2 id="custom-filtering-behavior"&gt;Custom filtering behavior&lt;/h2&gt;
&lt;p&gt;Similarly, you can customize filtering by subclassing &lt;code&gt;QSortFilterProxyModel&lt;/code&gt; and overriding &lt;code&gt;filterAcceptsRow&lt;/code&gt;. This method is called for every row in the source model, and it should return &lt;code&gt;True&lt;/code&gt; if the row should be visible.&lt;/p&gt;
&lt;p&gt;Here's an example that filters to show only rows where the "Age" column (column 1) is above a certain threshold:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;class AgeFilterProxyModel(QSortFilterProxyModel):
    def __init__(self):
        super().__init__()
        self._min_age = 0

    def set_min_age(self, age):
        self._min_age = age
        self.invalidateFilter()  # Re-apply the filter

    def filterAcceptsRow(self, source_row, source_parent):
        index = self.sourceModel().index(source_row, 1, source_parent)
        age = self.sourceModel().data(index, Qt.ItemDataRole.DisplayRole)
        try:
            return int(age) &amp;gt;= self._min_age
        except (ValueError, TypeError):
            return True
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After changing your filter criteria, call &lt;code&gt;invalidateFilter()&lt;/code&gt; to tell the proxy model to re-evaluate which rows should be shown.&lt;/p&gt;
&lt;p&gt;You can combine this with the text-based column filtering too. If you override &lt;code&gt;filterAcceptsRow&lt;/code&gt;, you have full control &amp;mdash; you can check multiple columns, apply complex logic, or combine several filter conditions:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;def filterAcceptsRow(self, source_row, source_parent):
    model = self.sourceModel()

    # Check age filter
    age_index = model.index(source_row, 1, source_parent)
    age = model.data(age_index, Qt.ItemDataRole.DisplayRole)
    if int(age) &amp;lt; self._min_age:
        return False

    # Check text filter on city column
    city_index = model.index(source_row, 2, source_parent)
    city = model.data(city_index, Qt.ItemDataRole.DisplayRole)
    if self.filterRegularExpression().pattern():
        if not self.filterRegularExpression().match(city).hasMatch():
            return False

    return True
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 id="putting-it-all-together"&gt;Putting it all together&lt;/h2&gt;
&lt;p&gt;Here's a complete example that combines sorting, text filtering, and a numeric age filter using a custom proxy model:&lt;/p&gt;
&lt;div class="code-block"&gt;
&lt;span class="code-block-language code-block-python"&gt;python&lt;/span&gt;
&lt;pre&gt;&lt;code class="python"&gt;import sys
from PyQt6.QtCore import Qt, QAbstractTableModel, QSortFilterProxyModel
from PyQt6.QtWidgets import (
    QApplication, QMainWindow, QTableView,
    QVBoxLayout, QHBoxLayout, QWidget,
    QLineEdit, QLabel, QSpinBox,
)


class TableModel(QAbstractTableModel):
    def __init__(self, data):
        super().__init__()
        self._data = data
        self._headers = ["Name", "Age", "City"]

    def data(self, index, role):
        if role == Qt.ItemDataRole.DisplayRole:
            return self._data[index.row()][index.column()]

    def rowCount(self, index):
        return len(self._data)

    def columnCount(self, index):
        return len(self._data[0])

    def headerData(self, section, orientation, role):
        if role == Qt.ItemDataRole.DisplayRole:
            if orientation == Qt.Orientation.Horizontal:
                return self._headers[section]


class CustomFilterProxyModel(QSortFilterProxyModel):
    def __init__(self):
        super().__init__()
        self._min_age = 0
        self._city_filter = ""

    def set_min_age(self, age):
        self._min_age = age
        self.invalidateFilter()

    def set_city_filter(self, text):
        self._city_filter = text.lower()
        self.invalidateFilter()

    def filterAcceptsRow(self, source_row, source_parent):
        model = self.sourceModel()

        # Age filter (column 1)
        age_index = model.index(source_row, 1, source_parent)
        age = model.data(age_index, Qt.ItemDataRole.DisplayRole)
        try:
            if int(age) &amp;lt; self._min_age:
                return False
        except (ValueError, TypeError):
            pass

        # City text filter (column 2)
        if self._city_filter:
            city_index = model.index(source_row, 2, source_parent)
            city = model.data(city_index, Qt.ItemDataRole.DisplayRole)
            if self._city_filter not in str(city).lower():
                return False

        return True


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        data = [
            ["Alice", 25, "New York"],
            ["Bob", 30, "Denver"],
            ["Charlie", 35, "Austin"],
            ["Diana", 28, "Denver"],
            ["Eve", 22, "Austin"],
            ["Frank", 40, "New York"],
            ["Grace", 19, "Denver"],
        ]

        self.model = TableModel(data)

        self.proxy_model = CustomFilterProxyModel()
        self.proxy_model.setSourceModel(self.model)

        self.table = QTableView()
        self.table.setModel(self.proxy_model)
        self.table.setSortingEnabled(True)
        self.table.clicked.connect(self.cell_clicked)

        # City filter
        self.city_input = QLineEdit()
        self.city_input.setPlaceholderText("Filter by city...")
        self.city_input.textChanged.connect(self.proxy_model.set_city_filter)

        # Age filter
        self.age_spin = QSpinBox()
        self.age_spin.setRange(0, 100)
        self.age_spin.setPrefix("Min age: ")
        self.age_spin.valueChanged.connect(self.proxy_model.set_min_age)

        filter_layout = QHBoxLayout()
        filter_layout.addWidget(QLabel("City:"))
        filter_layout.addWidget(self.city_input)
        filter_layout.addWidget(self.age_spin)

        layout = QVBoxLayout()
        layout.addLayout(filter_layout)
        layout.addWidget(self.table)

        self.status_label = QLabel("Click a row to see details")
        layout.addWidget(self.status_label)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)
        self.setWindowTitle("QTableView &amp;mdash; Sort &amp;amp; Custom Filter")
        self.resize(500, 400)

    def cell_clicked(self, proxy_index):
        source_index = self.proxy_model.mapToSource(proxy_index)
        row = proxy_index.row()
        name = self.proxy_model.data(
            self.proxy_model.index(row, 0),
            Qt.ItemDataRole.DisplayRole,
        )
        age = self.proxy_model.data(
            self.proxy_model.index(row, 1),
            Qt.ItemDataRole.DisplayRole,
        )
        city = self.proxy_model.data(
            self.proxy_model.index(row, 2),
            Qt.ItemDataRole.DisplayRole,
        )
        self.status_label.setText(
            f"Selected: {name}, age {age}, from {city} "
            f"(source row: {source_index.row()})"
        )


app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img alt="Complete example with sorting and dual filters &amp;mdash; city text search and minimum age." src="sort-filter-complete.png"/&gt;&lt;/p&gt;
&lt;p&gt;Try playing with this example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Click column headers to sort by name, age, or city.&lt;/li&gt;
&lt;li&gt;Type in the city filter to narrow down results.&lt;/li&gt;
&lt;li&gt;Adjust the minimum age spinner to hide younger entries.&lt;/li&gt;
&lt;li&gt;Click on rows and notice how the source row number differs from the visible row number.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="summary"&gt;Summary&lt;/h2&gt;
&lt;p&gt;Here's a quick recap of everything we covered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;QSortFilterProxyModel&lt;/code&gt;&lt;/strong&gt; sits between your model and your view. It sorts and filters data without modifying the source.&lt;/li&gt;
&lt;li&gt;Call &lt;strong&gt;&lt;code&gt;setSortingEnabled(True)&lt;/code&gt;&lt;/strong&gt; on the view to let users sort by clicking column headers.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;&lt;code&gt;setFilterKeyColumn()&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;setFilterFixedString()&lt;/code&gt;&lt;/strong&gt; for quick text filtering. Set the column to &lt;code&gt;-1&lt;/code&gt; to search all columns.&lt;/li&gt;
&lt;li&gt;Always use &lt;strong&gt;&lt;code&gt;mapToSource()&lt;/code&gt;&lt;/strong&gt; when you need to convert a proxy index back to the source model's coordinate system.&lt;/li&gt;
&lt;li&gt;Emit &lt;strong&gt;&lt;code&gt;layoutAboutToBeChanged&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;layoutChanged&lt;/code&gt;&lt;/strong&gt; when replacing data in the source model to avoid crashes.&lt;/li&gt;
&lt;li&gt;Subclass &lt;code&gt;QSortFilterProxyModel&lt;/code&gt; and override &lt;strong&gt;&lt;code&gt;lessThan()&lt;/code&gt;&lt;/strong&gt; for custom sorting or &lt;strong&gt;&lt;code&gt;filterAcceptsRow()&lt;/code&gt;&lt;/strong&gt; for custom filtering.&lt;/li&gt;
&lt;li&gt;Call &lt;strong&gt;&lt;code&gt;invalidateFilter()&lt;/code&gt;&lt;/strong&gt; after changing filter criteria in a custom proxy model.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The proxy model pattern is one of the most powerful parts of Qt's model/view architecture. Once you have it set up, you get flexible data presentation without ever duplicating or restructuring your underlying data. To explore model/view further, see how to &lt;a href="https://www.pythonguis.com/tutorials/pyqt6-qtableview-modelviews-numpy-pandas/"&gt;display numpy and pandas data in a QTableView&lt;/a&gt; or learn about &lt;a href="https://www.pythonguis.com/tutorials/pyqt6-signals-slots-events/"&gt;signals, slots, and events&lt;/a&gt; that power these interactions.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 06 May 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-05-06:/faq/add-some-explanation-on-sorting-a-qtableview/</guid><category>PyQt5</category><category>PyQt6</category><category>PySide2</category><category>PySide6</category><category>QTableView</category><category>QSortFilterProxyModel</category><category>Model-View</category></item><item><title>Streamlit Buttons — Making things happen with Streamlit buttons</title><link>https://www.pythonguis.com/tutorials/streamlit-buttons/</link><description>Streamlit is a popular choice for creating interactive web applications in Python. With its simple syntax and intuitive interface, developers can quickly create visually appealing dashboards.</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Fri, 01 May 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-05-01:/tutorials/streamlit-buttons/</guid><category>streamlit</category><category>foundation</category><category>buttons</category><category>streamlit-foundation</category></item><item><title>Actions in one thread changing data in another — How to communicate between threads and windows in PyQt6</title><link>https://www.pythonguis.com/faq/actions-in-one-thread-changing-data-in-another/</link><description>I have a main window that starts background threads (e.g., handling GPIO data). From the main window I open secondary windows using buttons. When I press a button in a secondary window, I can't change anything in the background threads. But if I press a button in the main window, everything works. How do I communicate between a secondary window and a thread that was started from the main window?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Martin Fitzpatrick</dc:creator><pubDate>Wed, 29 Apr 2026 06:00:00 +0000</pubDate><guid>tag:www.pythonguis.com,2026-04-29:/faq/actions-in-one-thread-changing-data-in-another/</guid><category>pyqt6</category><category>multithreading</category><category>signals</category><category>qthread</category><category>python</category><category>qt</category><category>qt6</category></item></channel></rss>