Results 1 to 7 of 7

Thread: Do Qt Style Sheets support List-style-image?

  1. #1
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Question Do Qt Style Sheets support List-style-image?

    I want to customize the image of a QToolButton By Using a QSS(Qt Style sheet) file.
    However,the button's normal , hovered , clicked image are just in one PNG file.
    I wonder if Qt style sheet support list-style image property,or is there any way to handle this problem?
    Or i could only use seperate PNG files?

    Thanks to Any reply.

  2. #2
    Join Date
    Mar 2010
    Posts
    63
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: Do Qt Style Sheets support List-style-image?

    You can customize QToolButton .QT documentation describe it in details

    Check this If this is helpful to you

    Customizing QToolButton

    There are three types of QToolButtons.
    he QToolButton has no menu. In this case, the QToolButton is styled exactly like QPushButton. See Customizing QPushButton for an example.
    The QToolButton has a menu and has the QToolButton::popupMode set to QToolButton::DelayedPopup or QToolButton::InstantPopup. In this case, the QToolButton is styled exactly like a QPushButton with a menu. See Customizing QPushButton for an example of the usage of the menu-indicator pseudo state.
    The QToolButton has its QToolButton::popupMode set to QToolButton::MenuButtonPopup. In this case, we style it as follows:


    ToolButton { /* all types of tool button */
    border: 2px solid #8f8f91;
    border-radius: 6px;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    stop: 0 #f6f7fa, stop: 1 #dadbde);
    }

    QToolButton[popupMode="1"] { /* only for MenuButtonPopup */
    padding-right: 20px; /* make way for the popup button */
    }

    QToolButton:pressed {
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    stop: 0 #dadbde, stop: 1 #f6f7fa);
    }

    /* the subcontrols below are used only in the MenuButtonPopup mode */
    QToolButton::menu-button {
    border: 2px solid gray;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    /* 16px width + 4px for border = 20px allocated above */
    width: 16px;
    }

    QToolButton::menu-arrow {
    image: url(downarrow.png);
    }

    QToolButton::menu-arrow:open {
    top: 1px; left: 1px; /* shift it a bit */
    }

  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Do Qt Style Sheets support List-style-image?

    Just use seperate png files

  4. #4
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Do Qt Style Sheets support List-style-image?

    Wow, display many icons in one PNG file seems to save more space.
    If there's no solution,I will just use seperate PNG files.
    Hope Qt could add this in a future version.

  5. #5
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: Do Qt Style Sheets support List-style-image?

    Yeah but how do you think that you access the desired icon from one png?

  6. #6
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Do Qt Style Sheets support List-style-image?

    In CSS there is a way to define width & height of each icon in a PNG file.Anyway...
    Another problem is that yesterday Qt Labs announced a technical preview of Qt 4.7& Qt creator 2.0 alpha.I downloaded creator 2.0 alpha,installed while I have already installed Qt 4.6.2.
    When compiling(release) a project I found that all image using './resources/...' file url doesn't work.The images just disappeared.But that not appear in creator 1.3.1

    -----------------update------------------
    well , at first the 'resources' DIR was in 'release' folder.When I copy this folder to the project folder, all things returned to be all right.Maybe there's a change in Qt's file system? Strange.
    Last edited by daiheitan; 12th March 2010 at 02:10.

  7. #7
    Join Date
    Mar 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Do Qt Style Sheets support List-style-image?

    Oh I made a stupid mistake.
    Just ignore my last post...

Similar Threads

  1. style sheets
    By alisami in forum Qt Programming
    Replies: 8
    Last Post: 7th May 2009, 10:41
  2. BIG Problem with Background-image using Style Sheets
    By PiXeL16 in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 23:10
  3. BG image on QPushButton using style sheets??
    By JimDaniel in forum Newbie
    Replies: 2
    Last Post: 13th September 2007, 04:31
  4. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 18:03
  5. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 16:14

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.