Results 1 to 5 of 5

Thread: Automatically resizing custom QWidget based on runtime specifications

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2013
    Location
    Texas, U.S.A.
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Question Automatically resizing custom QWidget based on runtime specifications

    I have a custom QWidget that displays some number of QSliders, depending on the labels passed into its constructor:

    Qt Code:
    1. NodeEditBox(QWidget* _parent, vector<string> _sliderLabels);
    To copy to clipboard, switch view to plain text mode 

    So, for example, the box would look like this if 4 labels "X", "Y", "Z", and "theta" were passed in:

    ExpandedNode.png

    I want to automatically resize the NodeEditBox depending on the number of sliders it will have. One way that works is just doing this right in the beginning of the constructor body:

    Qt Code:
    1. resize(450, 75*(_sliderLabels.size()));
    To copy to clipboard, switch view to plain text mode 

    ...But it doesn't always scale quite right and can look sloppy (e.g., what works nicely for 3 sliders doesn't work for one.) Is there a way I can be more clean about it and just require that the NodeEditBox always displays all of its widgets?
    Last edited by nicole.cpp; 26th August 2013 at 23:47.

Similar Threads

  1. Replies: 2
    Last Post: 23rd October 2012, 01:10
  2. Problem with automatically resizing label text
    By glennr in forum Qt Programming
    Replies: 0
    Last Post: 4th January 2012, 22:11
  3. Replies: 2
    Last Post: 27th July 2011, 15:49
  4. QWidget stylesheets not right in runtime
    By Denarius in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2009, 11:21
  5. Resizing any kind of widget runtime
    By vajindarladdad in forum Qt Programming
    Replies: 1
    Last Post: 10th December 2008, 16: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.