Results 1 to 5 of 5

Thread: QtDesigner and Stylesheets

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Location
    Vancouver, Canada
    Posts
    54
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    17
    Thanked 2 Times in 2 Posts

    Default QtDesigner and Stylesheets

    Hello,

    I am trying to apply a style sheet stored in a file to my application. In particular, I would like to add padding to my QCombo-boxes, as such:

    Qt Code:
    1. padding: 3px;
    2. color: red;
    3. }
    To copy to clipboard, switch view to plain text mode 

    Note that I have added the red for testing purposes. I have several QComboBoxes, created in Qt Designer. If I apply the style sheet to the entire application (using
    Qt Code:
    1. qApp()->setStyleSheet(styleSheet)
    To copy to clipboard, switch view to plain text mode 
    ), the text turns red but does not add the padding. This means that I am correctly reading in the text file and applying it, but I am somehow not setting the padding property properly.

    Again, I tried setting the style sheet in the source code file that sets up the *.ui file.
    This works:
    Qt Code:
    1. this->setStyleSheet("QComboBox { color: red; }");
    To copy to clipboard, switch view to plain text mode 

    This doesn't:
    Qt Code:
    1. this->setStyleSheet("QComboBox { padding: 3px; }");
    To copy to clipboard, switch view to plain text mode 

    I can successfully pad them by adding a line of code for each:
    Qt Code:
    1. ui->ComboBox->setStyleSheet("QComboBox { padding: 3 px; }");
    To copy to clipboard, switch view to plain text mode 

    I can successfully change the style sheet in Qt Designer.

    However, both of the solutions above must be done for each combo box, which is tedious and (I think) unnecessary. Any help would be greatly appreciated. Thanks,

    AB

    edit: I am using Qt Designer with Qt Creator on a 64 bit Windows 7 machine. I am using Qt version 4.7.4 (32 bit).
    Last edited by abrou; 4th September 2012 at 22:56. Reason: Updating user-specific information

Similar Threads

  1. Another Question with StyleSheets
    By daiheitan in forum Qt Programming
    Replies: 7
    Last Post: 12th March 2010, 11:29
  2. Where to put my stylesheets?
    By martinn in forum Qt Programming
    Replies: 3
    Last Post: 2nd February 2010, 15:28
  3. Working with StyleSheets
    By BingoMaster in forum Newbie
    Replies: 3
    Last Post: 29th September 2009, 16:52
  4. Stylesheets
    By FuryCradle in forum Newbie
    Replies: 2
    Last Post: 26th September 2009, 21:34
  5. stylesheets with RGB
    By tommy in forum Qt Programming
    Replies: 4
    Last Post: 13th December 2007, 01:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.