[solved]UI Set



  • I have set some of property for Tab such as the
    @
    QGroupBox{border-image:url(:/image.png)} @

    in the file of qss, but when I add the code
    @
    "Tab->setStyleSheet("background-image:url(:/images/back.png)");"@

    , the background image has been set successfully, but the background of QLabel and QLineEdit in the QGroupBox has been changed.
    How do I do to set the background image but not influence the other component?
    Thank you.

    [edit, @ code tags added, please do so in the future to make your post easier to read, Eddy]


  • Moderators

    Hi,

    Have a look at "this page in the docs":http://developer.qt.nokia.com/doc/qt-4.8/stylesheet-syntax.html. It explains how to use stylesheets on specific widgets.



  • Thank you.
    I also want to know relationship about the .qss file and the code in program, whether they have the Priority?


  • Moderators

    [quote author="Lalita" date="1324974526"]Thank you.
    I also want to know relationship about the .qss file and the code in program, whether they have the Priority? [/quote]

    The general purpose of stylesheets is that you get a general look and feel of all the widgets in your app. Normally you set it in your main function on your QApplication.

    Setting a stylesheet in Qt Creator is nice for testing things out though.
    Anyway you could test it yourself : eg. use a red color in Qt Creator and a blue one in the qss... ;)



  • Thank you. I think it will be conflicting problem.I wil do research that.



  • Now I found the problem by modified above code:Tab->setStyleSheet("QTabWidget{background-image:url(:/images/back.png)}");


  • Moderators

    Great!
    Well done.

    If you consider this post as solved, please edit your first post and add [solved] in front of it.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.