Results 1 to 7 of 7

Thread: Designer doesn't connect the widgets

  1. #1
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Designer doesn't connect the widgets

    In Designer with Qt 4.4.3, I'm creating QPushButtons inside a QGBoxLayout, which is in turn inside a QGroupBox. The ui_*.h file that is generated contains these objects, but I have to manually connect the pushbuttons to the layout, and the layout to the group box in my code or the pushbuttons don't work:

    speedHorizontalLayout->addWidget(speed1PushButton);
    speedHorizontalLayout->addWidget(speedPoint1PushButton);
    speedHorizontalLayout->addWidget(speedPoint01PushButton);
    speedGroupBox->setLayout(speedHorizontalLayout);

    Am I doing something wrong, or is this a possible bug?

    Thanks,
    Martin

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Designer doesn't connect the widgets

    You are surely doing something wrong. What does "don't work" mean in this case? You can't see the buttons or you can't press them or what? BTW. There is no such thing as QGBoxLayout. Did you mean QGridLayout? Could you post the UI file or at least its screenshot?

  3. #3
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Designer doesn't connect the widgets

    Quote Originally Posted by wysota View Post
    You are surely doing something wrong. What does "don't work" mean in this case? You can't see the buttons or you can't press them or what? BTW. There is no such thing as QGBoxLayout. Did you mean QGridLayout? Could you post the UI file or at least its screenshot?
    That was a typo - I meant QHBoxLayout.

    The buttons are visible but can't be pressed. If you click on them, nothing at all happens.

    As noted, Designer did not auto-generate the code to put the pieces together. I had to add the following code to add the buttons to the layout, and to set the layout for the group box:

    speedHorizontalLayout->addWidget(speed1PushButton);
    speedHorizontalLayout->addWidget(speedPoint1PushButton);
    speedHorizontalLayout->addWidget(speedPoint01PushButton);
    speedGroupBox->setLayout(speedHorizontalLayout);

    It seems like adding the widgets to the layout and setting the group box's layout are things that Designer should do, but maybe they aren't.

    Thanks,
    Martin

  4. #4
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: Designer doesn't connect the widgets

    Quote Originally Posted by martinb0820 View Post
    If you click on them, nothing at all happens.
    You have to create a connection from clicked() signal in the QPushButton object to the method in the receiver object. Please see description of QObject::connect() n Qt Assistant for more details.

  5. The following user says thank you to pastor for this useful post:

    martinb0820 (4th November 2008)

  6. #5
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Designer doesn't connect the widgets

    Quote Originally Posted by pastor View Post
    You have to create a connection from clicked() signal in the QPushButton object to the method in the receiver object. Please see description of QObject::connect() n Qt Assistant for more details.
    I had connections and the buttons work fine if they are not inside the QGroupBox. Once inside the QGroupBox, they no longer work because Designer does not generate code to add them to the layout, and to set the QGroupBox's layout. Instead, I have to do the following manually:

    speedHorizontalLayout->addWidget(speed1PushButton);
    speedGroupBox->setLayout(speedHorizontalLayout);

    I can certainly do this for all the group boxes I'm using, but it's tedious and something for which I'd hope to get some help from Designer to increase my productivity.

    So the question is: Should Designer be generating this code for me, or do I have to do it manually? If Designer should be generating this code, could there be something in the objects' properties that needs to be set differently?

    Thanks,
    Martin

  7. #6
    Join Date
    Oct 2008
    Posts
    70
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Default Re: Designer doesn't connect the widgets

    I'm using Qt 4.4.3 (Windows, Lininux) and I don't have any problems with QPushButton inside QGroupBox. All works fine for me.

    Designer shouldn't generate any code. All code generated by UIC tool.

    Can you show your UI file (or it would be nice to see your simple example, which reproduce problem)?

  8. #7
    Join Date
    Aug 2008
    Location
    Cherry Hill, NJ USA
    Posts
    61
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: Designer doesn't connect the widgets

    The problem is resolved - I was pulling in the layout from the Qt Toolbox instead of right clicking inside the group box and selecting the layout.

Similar Threads

  1. Replies: 12
    Last Post: 23rd June 2008, 08:05
  2. Cannot drop widgets in Qt Designer 4.4.0
    By DerSchoeneBahnhof in forum Qt Tools
    Replies: 2
    Last Post: 19th June 2008, 17:18
  3. Qt Designer & Qt4, connect to my own slot.
    By geitosten in forum Newbie
    Replies: 2
    Last Post: 17th February 2007, 19:22
  4. Designer crashes when selecting some widgets
    By gwendal in forum Qt Tools
    Replies: 4
    Last Post: 21st July 2006, 13:18
  5. How to create pop up widgets in designer.
    By gsQT4 in forum Qt Tools
    Replies: 1
    Last Post: 25th May 2006, 16:40

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.