<div class="gmail_quote"><div>Hurray.. it worked.. Many thanks to you nickgeans and pyqt mailing list..<br> <br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Try to change the style sheet string:<br>
<br>
from: self.groupBox.setStyleSheet("background-color: rgb(255, 255,<br>
255); border:1px solid rgb(255, 170, 255);")<br>
to: self.groupBox.setStyleSheet("QGroupBox { background-color: rgb(255, 255,<br>
255); border:1px solid rgb(255, 170, 255); }")<br>
<br>
Thus adding QGroupBox and acolades..<br>
<br>
On Wed, Mar 10, 2010 at 2:51 PM, Jebagnana Das <<a href="mailto:jebagnanadas@gmail.com">jebagnanadas@gmail.com</a>>wrote:<br>
<br>
> Thanks for your quick reply.. Have a look at this minimal example.. In the<br>
> example i've applied stylesheet only for groupbox not to any of it's<br>
> components.. Since i've set the parent as groupbox for button,label and<br>
> combo box it also reflects the style sheet properties that is applied for<br>
> group box.. In the combo box after clicking when you hover a menu item it'll<br>
> not be visible since the focus is also in white color and it doesn't look<br>
> good (esp. in linux).. In button too all it's properties are lost including<br>
> click feel(in windows).. How can i prevent this.. Please help me..<br>
><br>
> from PyQt4 import QtCore, QtGui<br>
><br>
> class Ui_Dialog(object):<br>
><br>
> def setupUi(self, Dialog):<br>
><br>
> Dialog.setObjectName("Dialog")<br>
> Dialog.resize(399, 309)<br>
> Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog",<br>
> "Dialog", None, QtGui.QApplication.UnicodeUTF8))<br>
><br>
> self.groupBox = QtGui.QGroupBox(Dialog)<br>
> self.groupBox.setGeometry(QtCore.QRect(10, 10, 381, 291))<br>
> self.groupBox.setStyleSheet("background-color: rgb(255, 255,<br>
> 255);\n"<br>
> "border:1px solid rgb(255, 170, 255);")<br>
> self.groupBox.setObjectName("groupBox")<br>
><br>
> self.pushButton = QtGui.QPushButton(self.groupBox)<br>
> self.pushButton.setGeometry(QtCore.QRect(110, 130, 92, 28))<br>
> self.pushButton.setObjectName("pushButton")<br>
> self.pushButton.setText(QtGui.QApplication.translate("Dialog",<br>
> "Click Me", None, QtGui.QApplication.UnicodeUTF8))<br>
><br>
> self.label = QtGui.QLabel(self.groupBox)<br>
> self.label.setGeometry(QtCore.QRect(50, 30, 81, 18))<br>
> self.label.setObjectName("label")<br>
> self.label.setText(QtGui.QApplication.translate("Dialog", "Name :",<br>
> None, QtGui.QApplication.UnicodeUTF8))<br>
><br>
> self.lineEdit = QtGui.QLineEdit(self.groupBox)<br>
> self.lineEdit.setGeometry(QtCore.QRect(140, 30, 191, 26))<br>
> self.lineEdit.setObjectName("lineEdit")<br>
><br>
> self.comboBox = QtGui.QComboBox(self.groupBox)<br>
> self.comboBox.setGeometry(QtCore.QRect(140, 70, 85, 27))<br>
> self.comboBox.setObjectName("comboBox")<br>
> self.comboBox.addItem("")<br>
> self.comboBox.addItem("")<br>
> self.comboBox.addItem("")<br>
> self.comboBox.addItem("")<br>
> self.comboBox.addItem("")<br>
> self.comboBox.setItemText(0, QtGui.QApplication.translate("Dialog",<br>
> "2", None, QtGui.QApplication.UnicodeUTF8))<br>
> self.comboBox.setItemText(1, QtGui.QApplication.translate("Dialog",<br>
> "20", None, QtGui.QApplication.UnicodeUTF8))<br>
> self.comboBox.setItemText(2, QtGui.QApplication.translate("Dialog",<br>
> "12", None, QtGui.QApplication.UnicodeUTF8))<br>
> self.comboBox.setItemText(3, QtGui.QApplication.translate("Dialog",<br>
> "15", None, QtGui.QApplication.UnicodeUTF8))<br>
> self.comboBox.setItemText(4, QtGui.QApplication.translate("Dialog",<br>
> "234", None, QtGui.QApplication.UnicodeUTF8))<br>
><br>
><br>
> self.label_2 = QtGui.QLabel(self.groupBox)<br>
> self.label_2.setGeometry(QtCore.QRect(50, 70, 81, 18))<br>
> self.label_2.setObjectName("label_2")<br>
> self.label_2.setText(QtGui.QApplication.translate("Test Dialog",<br>
> "Number :", None, QtGui.QApplication.UnicodeUTF8))<br>
><br>
> QtCore.QMetaObject.connectSlotsByName(Dialog)<br>
><br>
><br>
> if __name__ == "__main__":<br>
> import sys<br>
> app = QtGui.QApplication(sys.argv)<br>
> Dialog = QtGui.QDialog()<br>
> ui = Ui_Dialog()<br>
> ui.setupUi(Dialog)<br>
> Dialog.show()<br>
> sys.exit(app.exec_())<br>
><br>
> P.S: I've used qt designer for quick designing.. Even if i hand code it the<br>
> result will be the same..<br>
><br>
><br>
><br>
>> You might take a look at so called "Selector types" (<br>
>> <a href="http://qt.nokia.com/doc/4.3/stylesheet-syntax.html#selector-types" target="_blank">http://qt.nokia.com/doc/4.3/stylesheet-syntax.html#selector-types</a>). Given<br>
>> a<br>
>> QDialog and its children (e.g. QPushButtons), this can prevent this<br>
>> cascading behaviour of styles, although I've never had any problems with<br>
>> that without using this way of "selecting" matching objects..<br>
>><br>
>> Can you show a small piece of code (small stylesheet and the way you apply<br>
>> it) please?<br>
>><br>
>> On Tue, Mar 9, 2010 at 9:05 PM, Jebagnana Das <<a href="mailto:jebagnanadas@gmail.com">jebagnanadas@gmail.com</a><br>
>> >wrote:<br>
>><br>
>> > Hello all,<br>
>> ><br>
>> > If i apply a property to a parent widget it is automatically applied for<br>
>> > child widgets too.. Is there any way of preventing this??<br>
>> ><br>
>> > For example if i set background color as white in a dialog then any<br>
>> > button,combo boxes and scroll bars(within the dialog) looks white and it<br>
>> > lacks it's native look(have to say it's unpleasant to the eyes(esp. in<br>
>> unix)<br>
>> > & ugly).. Is there any way that i can apply the stylesheets only to a<br>
>> parent<br>
>> > widget not to it's children? can i exclude specifically some child<br>
>> widgets<br>
>> > from not inheriting parent SS properties??<br>
>> ><br>
>> > _______________________________________________<br>
>> > PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
>> > <a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
>> ><br>
>><br>
><br>
<br>
<br>
--<br>
Nick Gaens<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100310/1cace5cc/attachment.html" target="_blank">http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100310/1cace5cc/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
PyQt mailing list<br>
<a href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a><br>
<a href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt" target="_blank">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a><br>
<br>
End of PyQt Digest, Vol 68, Issue 24<br>
************************************<br>
</blockquote></div><br>