Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Changing Contents when Slecting other widgets

Changing Contents when Slecting other widgets

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 287 Views 1 Watching
  • 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.
  • V Offline
    V Offline
    vinayak_420
    wrote on last edited by vinayak_420
    #1

    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtCore import *
    import sys

    def foo():
    app = QApplication(sys.argv)
    window = QWidget()
    window.setStyleSheet("""
    background-color: green;
    """)
    btn1 = QPushButton('My_Button', window)
    btn1.setStyleSheet("""
    QPushButton{
    background-color:yellow;
    }
    """)
    btn1.setGeometry(25,25,50,50)
    window.resize(100,100)
    window.show()
    sys.exit(app.exec())
    if name == "main":
    foo()

    If i press tab the My_Button is selected, so what i want is when i select a widget it changes content(here QWidget,background) of other widgets

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      One possible way to do that is to use a dynamic property that you set when the widget gets/loses focus.

      See here for an example of style sheet with dynamic properties.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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