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. Gradient Buttons (+/-) for lists on Mac OS X, others
Forum Updated to NodeBB v4.3 + New Features

Gradient Buttons (+/-) for lists on Mac OS X, others

Scheduled Pinned Locked Moved General and Desktop
4 Posts 4 Posters 3.3k 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.
  • C Offline
    C Offline
    CorgiDude
    wrote on last edited by
    #1

    Hello,

    I am attempting to write an application in Qt for both Mac OS X and Windows. In Cocoa on Mac OS X, there is something that Apple calls "Gradient Buttons". They are used for manipulating lists and column views, and are "standard" (OS-provided) buttons on that platform. They are "described in the Apple HIG":http://developer.apple.com/library/mac/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGControls/XHIGControls.html#//apple_ref/doc/uid/TP30000359-SW12 and I was wondering if Qt provided anything similar. I searched all of: the Internet (using keywords "gradient button qt" and "add and delete standard buttons in qt"), these forums, and Qt Assistant, and came up empty-handed.

    What I personally think would be best is something like QPushButtons with QPixmaps of the + and - symbols, at least on Windows. My concern is that on Mac OS X they will not be square or aligned as they are in the Apple HIG and then the app will not look 'native'.

    My question is: Does Qt provide something similar to Apple's gradient buttons? Or would I be able to set up a QPushButton so that it is at least very similar-looking on the Mac OS X platform?

    Thank you for your time.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I just read the HIG, and I am not sure what is so special about them really. To be honest, I think they look a bit alien to OSX in the examples shown on that page, if you ask me (and I know you don't). I think a QToolButton can work just as well? If you want to manipulate their shape, you might want to look into Qt Style Sheets.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        I would go with QToolBar, as André already suggested. It comes closest and is provided by Qt. Some styling should do the trick.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • S Offline
          S Offline
          serkol
          wrote on last edited by
          #4

          When there are several buttons in a strip of gradient buttons on OS X, they have a single-line frame between them. Because of that, they look like segments of a single control.

          To make this kind of buttons, I used QToolButton (not a QToolBar, just buttons in layouts), and styled them.

          I used 4 styles:

          the first (left) button in a strip.

          buttons in the middle in a strip.

          the last (right) button in a strip.

          a standalone button.

          These 4 styles draw different frames.

          This is what I did:

          1. A fragment of the style that I assign to the instance of QApplication (these styles use stretchable images that you need to draw or grab from OS X)

          @//
          // == QToolButton: segmented
          //
          "QToolButton[sgm_single="true"] { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrSUp.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_single="true"]:pressed { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrSDown.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_left="true"] { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrLUp.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_left="true"]:pressed { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrLDown.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_left="true"]:checked { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrLChecked.png) 4 4 4 4 ; "
          " color: white; "
          "} "
          "QToolButton[sgm_middle="true"] { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrMUp.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_middle="true"]:pressed { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrMDown.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_middle="true"]:checked { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrMChecked.png) 4 4 4 4 ; "
          " color: white; "
          "} "
          "QToolButton[sgm_right="true"] { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrRUp.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_right="true"]:pressed { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrRDown.png) 4 4 4 4 ; "
          "} "
          "QToolButton[sgm_right="true"]:checked { "
          " border-width: 4px; "
          " border-image: url(:/img/BPicTbrRChecked.png) 4 4 4 4 ; "
          " color: white; "
          "} "
          @

          1. In a constructor of a dialog with these special buttons

          @
          // a single button
          ui->btnWkPerfInfo->setProperty("sgm_single", true);
          //
          // 3 buttons in a strip
          ui->btnDayAdd->setProperty("sgm_left", true);
          ui->btnDayCopy->setProperty("sgm_middle", true);
          ui->btnDayDelete->setProperty("sgm_right", true);
          @

          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