Results 1 to 8 of 8

Thread: Sizing problem

  1. #1
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Sizing problem

    I have dialog with 2 QTreeWidgets. One of them hidden.
    The problem is - how adjust size of dialog to the minimum size. (Dialog appears with width which is enough for placing 2 QTreeWidgets)
    Attached Files Attached Files

  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: Sizing problem

    This should work:

    my_dialog::my_dialog (QWidget* p)
    :QDialog(p)
    {
    setupUi(this);
    treeWidget_2->hide();
    setMinimumSize( sizeHint() );
    }

    Marcel

  3. #3
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sizing problem

    No this is not works properly, because it sets Minimum size to sizeHint() - correct will be sizeHint()/2

  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: Sizing problem

    Have you tried it?
    Since one of the tree widgets is hidden the sizeHint of the dialog will be exactly the width of the visible tree widget.

    Marcel

  5. #5
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sizing problem

    Yes I have tried,

  6. #6
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sizing problem

    but I found solution
    We need to reimplemet sizeHint()

    my_dialog::my_dialog (QWidget* p)
    :QDialog(p)
    {
    setupUi(this);
    treeWidget_2->hide();
    resize(sizeHint());
    }
    my_dialog::~my_dialog()
    {
    }
    QSize my_dialog::sizeHint()
    {
    return QSize(treeWidget_2->geometry().width()+10,treeWidget_2->geometry().height()+50);
    }

  7. #7
    Join Date
    Oct 2006
    Posts
    16
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: Sizing problem

    we can only call resize without reimplementing sizeHint - it works

    But I want to extend the problem :

    Instead of 2 QTreeWidgets I have 1 custom widget in which this 2 QTreeWidgets exist
    one of them is hidden ... resize is not help in this case

  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: Sizing problem

    Apply what you did for the dialog to the custom widget,
    Set the minimum size of the custom widget to the size hint of the tree view that is visible.

    Let me know if works.

    Marcel

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15: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.