Random Color Generator with QColor

  • Share this:

Code introduction


This function generates a random color and returns a QColor object.


Technology Stack : PyQt5.QtGui.QColor, random

Code Type : Function

Code Difficulty : Beginner


                
                    
def random_color():
    from random import randint
    from PyQt5.QtGui import QColor

    def get_random_color():
        return QColor(randint(0, 255), randint(0, 255), randint(0, 255))

    return get_random_color()