[PyQt] PyQt Digest, Vol 68, Issue 24

Jebagnana Das jebagnanadas at gmail.com
Wed Mar 10 16:27:50 GMT 2010


Hurray.. it worked.. Many thanks to you nickgeans and pyqt mailing list..


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


More information about the PyQt mailing list