Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Need help with CSS
Forum Updated to NodeBB v4.3 + New Features

[Solved]Need help with CSS

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Davita
    wrote on last edited by
    #1

    Hello Geeks :)
    I'm having some troubles understanding how CSS works with Qt. I have a dialog and I want to define 1 global css for this particular dialog. The CSS should define visuals for different widgets located on my dialog. The problem is that I don't know how to do that. Currently I assign CSS to individual widgets, which causes duplication and I want to avoid that. I tried setting the following CSS to the dialog:
    @QLineEdit {
    padding: 1px;
    border-style: solid;
    border: 2px solid gray;
    border-radius: 8px;
    }
    @
    But it didn't assign that css to all QLineEdit widgets on that dialog. I'm missing something very trivial but don't know what. Your help is much appreciated.
    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      For the whole app, try:

      @
      qApp->setStyleSheet("QLineEdit { padding: 1px; border-style: solid; border: 2px solid gray; border-radius: 8px; }");
      @

      Just remember to use it early in your code :) Mind you, this is just one of many possible answers to your question.

      (Z(:^

      1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #3

        Oh, and by the way, it's called QSS in Qt :) As it is not really CSS, just similar in syntax and principles.

        Also, some links you might find useful:

        "Qt Style Sheets":http://developer.qt.nokia.com/doc/qt-4.7/stylesheet.html

        "Styles and Style Aware Widgets":http://developer.qt.nokia.com/doc/qt-4.7/style-reference.html#id-a3b2102f-dcbc-49d0-a3f4-d0004fb89606

        "The Style Sheet Syntax":http://developer.qt.nokia.com/doc/qt-4.7/stylesheet-syntax.html#id-0c0e1863-8e45-441f-a348-d89e3bbf388b

        As the last note, you may also try the new kid on the block, QML (Qt QUICK).

        (Z(:^

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Davita
          wrote on last edited by
          #4

          Thank you very much sierdzio, your answer helped a lot :)

          1 Reply Last reply
          0
          • J Offline
            J Offline
            jinyaki
            wrote on last edited by
            #5

            Thank you~
            Oh, It is very useful to me.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved