Results 1 to 2 of 2

Thread: How to add QButtongroup to Layout?

  1. #1
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to add QButtongroup to Layout?

    Originally I had two QRadioButtons withing Layout which in the end were no exclusive. Therefore I try to add them to a QButtonGroup. Unfortinately I could find no example or these were for Qt3.

    If there is a possibility to do all this mainly within the designer that would be great, but I dont know how. So in case please let me know.

    This is what I coded so far. But in the end it fails because the QButtonGroup is no widget and I have no idea to add it to the layout.

    Qt Code:
    1. radioButtonNoFFT = new QRadioButton(this);
    2. radioButtonNoFFT->setObjectName(QString::fromUtf8("radioButtonNoFFT"));
    3. radioButtonNoFFT->setChecked(true);
    4.  
    5. radioButtonFFT = new QRadioButton(this);
    6. radioButtonFFT->setObjectName(QString::fromUtf8("radioButtonFFT"));
    7.  
    8. buttongroup = new QButtonGroup(this);
    9. buttongroup->addButton(radioButtonNoFFT);
    10. buttongroup->addButton(radioButtonFFT);
    11.  
    12. gridLayoutButtonGroup = new QGridLayout(this);
    13. gridLayoutButtonGroup->setObjectName(QString::fromUtf8("gridLayoutButtonGroup"));
    14. gridLayoutButtonGroup->addWidget(buttongroup);
    15.  
    16. gridLayout->addLayout(gridLayoutButtonGroup, 1, 0, 1, 1);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2008
    Posts
    157
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to add QButtongroup to Layout?

    In the end I now found out that this is everthiny I need to do:
    Qt Code:
    1. setupUi(this);
    2.  
    3. buttongroup = new QButtonGroup(this);
    4. buttongroup->addButton(radioButtonNoFFT);
    5. buttongroup->addButton(radioButtonFFT);
    To copy to clipboard, switch view to plain text mode 
    finding this out however caused me about 2 hours of trying to find some code example and implement whatever I could find...

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  2. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 18:11
  3. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 23:54
  4. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 08:16
  5. QT4 layout of complex dialog is very slow
    By cboles in forum Qt Programming
    Replies: 15
    Last Post: 28th April 2006, 20:57

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.