Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to remove an icon from a QTabWidget?
Forum Updated to NodeBB v4.3 + New Features

How to remove an icon from a QTabWidget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 308 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    I've got QTabWidgets which are getting little icons, as per https://doc.qt.io/qt-5/qtabwidget.html#setTabIcon

    However there are situations where I want to remove the icon, so the tab goes back to what it looked like before the icon was set.

    With PyQt5 if I do thisWidget.setTabIcon(None) it fails, with the error argument 2 has unexpected type 'NoneType'.

    If it's not None, then what should I be feeding to setTabIcon() in order to remove the icon please? Is there some method like removeTabIcon() which I haven't found?

    Thanks

    jsulmJ 1 Reply Last reply
    0
    • D donquibeats

      I've got QTabWidgets which are getting little icons, as per https://doc.qt.io/qt-5/qtabwidget.html#setTabIcon

      However there are situations where I want to remove the icon, so the tab goes back to what it looked like before the icon was set.

      With PyQt5 if I do thisWidget.setTabIcon(None) it fails, with the error argument 2 has unexpected type 'NoneType'.

      If it's not None, then what should I be feeding to setTabIcon() in order to remove the icon please? Is there some method like removeTabIcon() which I haven't found?

      Thanks

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @donquibeats Did you try to set a null icon? You can construct one using default constructor: https://doc.qt.io/qt-5/qicon.html#QIcon

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • D Offline
        D Offline
        donquibeats
        wrote on last edited by
        #3

        That works, thanks. I should've thought of trying thisWidget.setTabIcon(QIcon())

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved