Results 1 to 6 of 6

Thread: query w.r.t QGroupBox

  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default query w.r.t QGroupBox

    How do i get the group box title in a larger font and a different color?

    How do I change the color/thickness etc of the group box frame?

    Thanks

    Nupul

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: query w.r.t QGroupBox

    How do i get the group box title in a larger font and a different color?
    I think the title box is a label, so you can use rich text and change the font and color.

    How do I change the color/thickness etc of the group box frame?
    For this I think you will have to use QStyle.

  3. #3
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: query w.r.t QGroupBox

    This is what i did....

    Group box is a widget so I set it's palette and I could get a different frame color.
    Now the thing is this....The Widget Window's text is set to white and that of the Group box is set to Dark-Yellow. If I change the color of the group box to white....all the window text defaults to black!!! Could anyone explain what is wrong!!!

    Thanks

    Nupul

  4. #4
    Join Date
    May 2006
    Location
    Australia
    Posts
    53
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: query w.r.t QGroupBox

    can you show us some code?

  5. #5
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: query w.r.t QGroupBox

    sure...here's the code...

    Qt Code:
    1. MyMenuLayout::MyMenuLayout(QWidget *parent) : QWidget(parent)
    2. {
    3. main_layout = new QHBoxLayout;
    4.  
    5. v_right = new QVBoxLayout;
    6. v_middle = new QVBoxLayout;
    7. v_left = new QVBoxLayout;
    8.  
    9. grpbox_right = new QGroupBox();
    10. grpbox_middle = new QGroupBox();
    11. grpbox_left = new QGroupBox();
    12.  
    13. buttongrp_right = new QButtonGroup(grpbox_right);
    14. buttongrp_middle = new QButtonGroup(grpbox_middle);
    15. buttongrp_left = new QButtonGroup(grpbox_left);
    16.  
    17. connect(buttongrp_left,SIGNAL(buttonClicked(int)),this,SLOT(leftGroupButtonClicked(int)));
    18. connect(buttongrp_middle,SIGNAL(buttonClicked(int)),this,SLOT(middleGroupButtonClicked(int)));
    19. connect(buttongrp_right,SIGNAL(buttonClicked(int)),this,SLOT(rightGroupButtonClicked(int)));
    20.  
    21. //Set layout margins and inter-widget spacing.
    22.  
    23. v_right->setMargin(2);
    24. v_right->setSpacing(3);
    25.  
    26. v_left->setMargin(2);
    27. v_left->setSpacing(3);
    28.  
    29. v_middle->setMargin(2);
    30. v_middle->setSpacing(3);
    31.  
    32. //set group box flat for a particular effect.
    33.  
    34. grpbox_right->setFlat(true);
    35. grpbox_left->setFlat(true);
    36. grpbox_middle->setFlat(true);
    37.  
    38. //set a different frame color for the group boxes
    39.  
    40. grpbox_right->setPalette(QPalette(Qt::darkYellow));
    41. grpbox_left->setPalette(QPalette(Qt::darkYellow));
    42. grpbox_middle->setPalette(QPalette(Qt::darkYellow));
    43.  
    44.  
    45. // setWindowFlags(Qt::SubWindow|Qt::FramelessWindowHint);
    46. setWindowTitle("My Menu!");
    47.  
    48. setFont(QFont("Helvetica", 12, QFont::Bold));
    49.  
    50. setGeometry(50,50,900,500);
    51.  
    52. setMenuBackground();
    53.  
    54. }
    55.  
    56. void MyMenuLayout::setMenuBackground()
    57. {
    58. //read background image
    59.  
    60. QSettings bg_settings("./mymenu.background",QSettings::IniFormat);
    61. bg_settings.beginGroup("Menu Background");
    62.  
    63. QString bg_image = bg_settings.value("menu_bg_img").toString();
    64.  
    65. palette = QWidget::palette();
    66.  
    67. //set bg image and button/window colors.
    68.  
    69. brush = QPixmap(bg_image);
    70. palette.setBrush(QPalette::Window,brush);
    71. palette.setBrush(QPalette::ButtonText, Qt::white);
    72. palette.setBrush(QPalette::Button, Qt::darkBlue);
    73. palette.setBrush(QPalette::WindowText, Qt::white);
    74. setPalette(palette);
    75.  
    76.  
    77. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: query w.r.t QGroupBox

    a life without programming is like an empty bottle

  7. The following user says thank you to zlatko for this useful post:

    nupul (4th May 2006)

Similar Threads

  1. Dynamically changing QGroupBox size
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2007, 15: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.