Results 1 to 13 of 13

Thread: How to work with the replaceWidget function from QGridLayout

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to work with the replaceWidget function from QGridLayout

    As you found out yourself already, you need of course create instances of StationCard before you can add them.

    Qt Code:
    1. stationVector[k] = new StationCard
    To copy to clipboard, switch view to plain text mode 

    You experience a crash because your StationCard constructor tries to add an uninitialized pointer (propLabel) to a layout.
    Create a QLabel instance first

    Cheers,
    _

    P.S.: you can do the StationCard in designer if you want to, just use the widget template for a designer form and add the "ui" pointer and related code lines manually to your class

  2. The following user says thank you to anda_skoa for this useful post:

    KeineAhnung (30th April 2014)

  3. #2
    Join Date
    Apr 2014
    Posts
    116
    Thanks
    8
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: How to work with the replaceWidget function from QGridLayout

    Thanks for the help! Now the program is running and I can tackle the next step to connect the checkbox from the group box. As you can see I am missing a lot of the basic stuff but I am just not good at reading books. I always try to start in the middle...

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to work with the replaceWidget function from QGridLayout

    You can "forward" signals

    Qt Code:
    1. class StationCard : public QGroupBox
    2. {
    3. signals:
    4. void somethingToggled(bool on);
    5. };
    6.  
    7.  
    8. StationCard::StationCard()
    9. {
    10. connect(someCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(somethingToggled(bool)));
    11. }
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

Similar Threads

  1. Replies: 15
    Last Post: 23rd December 2013, 06:38
  2. Replies: 7
    Last Post: 30th August 2013, 14:01
  3. Replies: 0
    Last Post: 6th November 2011, 14:27
  4. Delete a QGridLayout and New QGridLayout at runtime
    By sabeesh in forum Qt Programming
    Replies: 1
    Last Post: 5th November 2007, 13:01
  5. qSort doesn't work with member function
    By ber_44 in forum Qt Programming
    Replies: 10
    Last Post: 2nd June 2007, 12:00

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.