Results 1 to 3 of 3

Thread: QDataWidgetMapper with QGroupBox

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2009
    Location
    Copenhagen
    Posts
    50
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QDataWidgetMapper with QGroupBox

    I'm trying to get a QGroupBox cheked state to change with an QDataWidgetMapper. I'm using a model with several controls and the QDataWidgetMapper being one of them. I want a group of controls to be displayed or hidden based on the value in the QDataWidgetMapper that can take on the value 0 or 1.

    For all of the controls it's no problem, but for the QGroupBox I can't get it to react.

    Qt Code:
    1. mapper = new QDataWidgetMapper(this);
    2. mapper->setModel(mymodel);
    3.  
    4. QLabel *lbl_acc_code = new QLabel("Code",this);
    5. QLineEdit *txt_acc_code = new QLineEdit(this);
    6. lbl_acc_code->setBuddy(txt_acc_code);
    7. mapper->addMapping(txt_acc_code, 0);
    8.  
    9. QLabel *lbl_acc_name = new QLabel("Name",this);
    10. QLineEdit *txt_acc_name = new QLineEdit(this);
    11. mapper->addMapping(txt_acc_name, 1);
    12.  
    13. QGroupBox *groupBox = new QGroupBox(tr("Incl. controls"),this);
    14. groupBox->setCheckable(true);
    15. groupBox->setChecked(false);
    16. //mapper->addMapping(groupBox,2) ; //I've tried this
    17. //The mapper has the value 0 or 1 at position 2. This should determine if the group is checked or not
    18. mapper->addMapping(groupBox,2,"setChecked(bool)") ; //This doesn't work either
    To copy to clipboard, switch view to plain text mode 

    I've even tried to add a dummy checkbox to connect to the mapper and then signal/slot with the groupbox.

    Is it possible to connect the QGroupBoxs checked state to the mapper?

    Thanks

  2. #2
    Join Date
    May 2009
    Location
    Copenhagen
    Posts
    50
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDataWidgetMapper with QGroupBox

    Guys!!

    I've tried everything now and I'm still not able to bind the mapper with the groupbox (setChecked property) in a way that it works.

    Can this really be true that no one can help me out with problem?

    Let me know thanks!

  3. #3
    Join Date
    Dec 2006
    Location
    Kędzierzyn-Koźle
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDataWidgetMapper with QGroupBox

    Quote Originally Posted by Nightfox View Post

    Qt Code:
    1. the group is checked or not
    2. mapper->addMapping(groupBox,2,"setChecked(bool)") ; //This doesn't work either
    To copy to clipboard, switch view to plain text mode 

    I've even tried to add a dummy checkbox to connect to the mapper and then signal/slot with the groupbox.

    Is it possible to connect the QGroupBoxs checked state to the mapper?

    Thanks
    Did you try
    Qt Code:
    1. mapper->addMapping(groupBox,2,"checked") ;
    To copy to clipboard, switch view to plain text mode 

    Please refer to documentation, "checked" is name of the porperty setChecked(bool) is name of the slot to set that property.

    Hope it helps

Similar Threads

  1. QDataWidgetMapper with QTreeView
    By Nightfox in forum Qt Programming
    Replies: 2
    Last Post: 1st September 2009, 19:58
  2. Minimum QGroupBox size
    By klnusbaum in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2008, 17:22
  3. Dynamically changing QGroupBox size
    By T4ng10r in forum Qt Programming
    Replies: 5
    Last Post: 30th March 2007, 15:02
  4. QGroupBox Issues
    By ToddAtWSU in forum Qt Programming
    Replies: 8
    Last Post: 16th January 2007, 13:45
  5. QGroupBox title truncated on both sides
    By Gopala Krishna in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2006, 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
  •  
Qt is a trademark of The Qt Company.