Results 1 to 12 of 12

Thread: problem with Tool button n Layout

  1. #1
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default problem with Tool button n Layout

    Hi all

    I am new to Qt and I used Designer to form a dialog. It looks good in the preview. But when I subclass it and use in a program, I have one the tool butttons alone elongated. The rest are all fine. I have attached the screenshot for reference. The problem is with the button in 3rd row and 2nd column. I did not write any code to change the size at all.

    What could be the reason? Kindly help me.

    Arjun
    Attached Images Attached Images

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout

    What layout did you use?
    I think it is better if you'd post the UI.

  3. #3
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: problem with Tool button n Layout

    I used a Grid layout. I have attached my UI.

    Also, one more question, is there a way to allign the tool buttons to the center of each grid?

    Thanks
    Arjun
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout

    Everything seems alright, except that you don't have a top level layout.
    Maybe there's something wrong in your code.
    How do you set those images for the buttons? Do you alter their sizes in any way?
    Are the images all the same size?

    Also, one more question, is there a way to allign the tool buttons to the center of each grid?
    Not sure what you mean.
    Do you want them to be horizontally centered relatively to the top labels?

    Regards

  5. #5
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: problem with Tool button n Layout

    Everything seems alright, except that you don't have a top level layout.
    Maybe there's something wrong in your code.
    How do you set those images for the buttons? Do you alter their sizes in any way?
    Are the images all the same size?
    I just have these 2 components in the dialog. Should I have a top level layout compulsarily?
    No I do not alter their sizes.
    Yes. All are of the same image size.

    Not sure what you mean.
    Do you want them to be horizontally centered relatively to the top labels?
    Yes. Horizontally center aligned.

    Thanks
    Arjun

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout

    Use this one.
    The layout got pretty complex, but it works.

    May I suggest that instead of using two columns of buttons use only one and select with a combo box or a check box whether you're modifying the stroke or fill color?

    Regards

  7. #7
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: problem with Tool button n Layout

    Use this one.
    The layout got pretty complex, but it works.
    I did not get you. Use which one? Did you attach any file to the message. I do not see it. If you dont mind can you attach it again.

    May I suggest that instead of using two columns of buttons use only one and select with a combo box or a check box whether you're modifying the stroke or fill color?
    Thanks for the suggestion. But I still would like it this way.

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout


    Sorry. I forgot to upload it. Must be the heat.

    Here's the attachment too.

    Regards
    Attached Files Attached Files

  9. The following user says thank you to marcel for this useful post:

    arjunasd (24th July 2007)

  10. #9
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: problem with Tool button n Layout

    Thanks a lot. It works perfect now.

    Also, one final question: How to make the dialog to have a fixed size. I made the sizepolicy to be [Fixed,Fixed,0,0] but still it grows.

    So I am not sure how to make it of fixed size?

    Thanks
    Arjun

  11. #10
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout

    Use the following code in the constructor of the QDialog subclass:

    Qt Code:
    1. setFixedSize(sizeHint());
    To copy to clipboard, switch view to plain text mode 
    This is a common solution.

    Another, better solution, but requires a top level layout (you have one ), is:
    Qt Code:
    1. layout()->setSizeConstraint(QLayout::FixedSize);
    To copy to clipboard, switch view to plain text mode 
    This will keep the dialog at a fixed size, but it will also adjust the size in some situations, like when the system font changes.

    Regards

  12. #11
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: problem with Tool button n Layout

    Great help man. Thanks a lot.

  13. #12
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with Tool button n Layout

    You're welcome.

Similar Threads

  1. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  2. Push Button problem!!
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2006, 16:31
  3. Facing problem with tool bar icons
    By jnana in forum Qt Programming
    Replies: 4
    Last Post: 20th April 2006, 08:37
  4. Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 4
    Last Post: 19th April 2006, 11:08

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.