'PyQt5 Change QMenuBar/QMenu addSeparator() Line Color

I have been trying to change the color of the line separator (.addSeparator()) for the PyQt5 QMenuBar/QMenu. Being that the color of the line separator is gray, it does not show up with a black background. I have been looking for a solution for several days but have not yet come across anything regarding this specific topic.

Below you will find a number of ways I tried to change the color of the .addSeparator() line to red. Could someone please help me with a solution to this problem?

# Does nothing
QMenuBar::separator {
    
        color: red;
}


# Changes menubar color to red
QMenuBar::item:separator {
    
        color: red;
}


# Changes menubar color to red
QMenuBar::item:line:separator {
    
        color: red;
}

# Changes menubar color to red
QMenuBar::item:line-separator {
    
        color: red;
}

# Does nothing
QMenuBar::line-separator {
    
        color: red;
}

# Does nothing
QMenuBar::line:separator {
    
        color: red;
}

# Does nothing
QMenu::line:separator {
    
        color: red;
}

# Does nothing
QMenu::line-separator {
    
        color: red;
}

# Does nothing
QMenu::line {
    
        color: red;
}

# Changes MenuItem color to red
QMenu::item:line {
    
        color: red;
}

# Changes MenuItem color to red
QMenu::item:line {
    
        color: red;
}

Here is the code in its entirety. NOTE: The code for the QMenuBar is in another file named Test_Class.py as indicated by the import statement import Test_Class

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


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


def main():
    App = QApplication(sys.argv)

    App.setStyleSheet(

        """
        
        QMenuBar {
            
            font-family: Times;
            font-size: 14pt;
        
        }
        
        QMenu {
            
            font-family: Times;
            font-size: 14pt;
        
        }
        
        QMenu::item:selected {
        
            background-color: #68B6F9;
        
        }
        
        QMenu::item-line:separator {
        
            color: red;
        
        }
        
        """
    )
    
    it_ = iITDemo()
    test_ = Test_Class.MainWindow()
    sys.exit(App.exec_())


if __name__ == '__main__':
    main()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source