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] Frame style for a group of buttons?
Forum Updated to NodeBB v4.3 + New Features

[Solved] Frame style for a group of buttons?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.5k 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
    dcortesi
    wrote on 7 Nov 2013, 00:13 last edited by
    #1

    I would like to display a group of radio buttons inside a "sunken" frame. (Yes, I know, modern style is flat. Humor me.) Just a rectangular border in the manner of a QFrame with frame shape StyledPanel and frameShadow "sunken", surrounding my radio set.

    QFrame is not actually a container. I do not want to use a QGroupBox because I do not want a title or space for a title -- in any case, I don't see how to set the frame properties of a group box. Right now I am using an HBoxLayout to contain the buttons but it does not allow for any styling. There is some idea I am not understanding...

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raven-worx
      Moderators
      wrote on 7 Nov 2013, 07:26 last edited by
      #2

      [quote author="dcortesi" date="1383783235"]
      QFrame is not actually a container. I do not want to use a QGroupBox because I do not want a title or space for a title[/quote]
      i don't know what you don't like about QFrame. QGroupBoix and QFrame are both widgets. QGroupBox just renders differently...
      So QFrame would be fine to use.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jeroentjehome
        wrote on 7 Nov 2013, 07:39 last edited by
        #3

        Hi,
        Think altering the stylesheet of the QFrame will do the trick., but like Raven mentioned, QFrame and QGroupbox are in basic the same with some small rendering differences.

        Greetz, Jeroen

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dcortesi
          wrote on 7 Nov 2013, 17:41 last edited by
          #4

          Thank you for the input but there is still something I just don't see. Explain like I'm five... I am trying this code (Python):
          @ radio_frame = QFrame()
          radio_frame.setFrameStyle(QFrame.StyledPanel)
          radio_frame.setFrameShadow(QFrame.Sunken)
          radio_frame.setLineWidth(3)
          btn_unicode = QRadioButton('Unicode',radio_frame)
          btn_unicode.setChecked(True) #start with unicode selected
          btn_html = QRadioButton('HTML',radio_frame)@
          This should make the two buttons children of the radio_frame, no? But when I addWidget(radio_frame) to a HBoxLayout, nothing appears. It is as if it had zero width, it just does not appear.

          If instead I do this:
          @ radio_hb = QHBoxLayout()
          btn_unicode = QRadioButton('Unicode',radio_frame)
          btn_unicode.setChecked(True) #start with unicode selected
          btn_html = QRadioButton('HTML',radio_frame)
          radio_hb.addWidget(btn_unicode)
          radio_hb.addWidget(btn_html)
          @
          I can addLayout(radio_hb) and the buttons appear, but of course with no style on their enclosure.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            raven-worx
            Moderators
            wrote on 8 Nov 2013, 07:23 last edited by
            #5

            setup your QFrame object like you already had. Add the buttons to your layout object. And finally set the layout on your widget. Now your widgets should appear with a border surrounded.

            btw. i don't think explaining programming to a five year old is easier :P

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dcortesi
              wrote on 9 Nov 2013, 02:56 last edited by
              #6

              OK, thank you! What I was missing was that you can use .setLayout() on any widget including a frame.

              So you make the frame you want, and you put the buttons in a box layout (which makes them exclusive), and you set that layout on the frame, which positions the buttons over the frame shape.

              1 Reply Last reply
              0

              1/6

              7 Nov 2013, 00:13

              • Login

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