Results 1 to 4 of 4

Thread: even expansion of combobox

  1. #1
    Join Date
    Mar 2014
    Location
    USA
    Posts
    85
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default even expansion of combobox

    I'm working in Qt Designer. There's more in the window than just these items, but the problem seems to be in the comboboxes so we'll focus on that. The window is a subclass of QWidget, not one of the dialog or main window classes. From here on out I'm going to refer to it as "the window." I've got a window that has a fixed width ListWidget on the left. In the center and right I have a combobox. Think of this as 3 "Columns." The center combobox has a member that is very long, but I want it to start at a shorter width index. The right combobox has a member that is long, but not as long as the center one. How can I set it so that the comboboxes' width are set to a shorter width than their widest member? When I get it set up, I put the window in a grid layout. As soon as I try to resize the window it automatically expands to the width necessary to hold the widest member of each of the 2 combo boxes and I can't make it any narrower. I can set it so that the window and comboxes start at the width I want but setting the minimum width of the comboboxes to the size I want (in this case about 116) and then setting the window size to the minimum I can to just fit all the widgets. I can do that by setting the narrower width as the minimum width of the comboboxes but that seems kind of shaky to me, but that could just be my paranoia. When I expand the window the comboboxes expand at the rate where the center one expands until it fits the widest member and then after it reaches that width then the width of the right combobox starts expanding until its width is the same as the center one and then they both start expanding at the same rate. How can I get it so that they start out at the same width and expand at the same rate when you widen the window? I would attach the ui file to make this easier to understand but my development computer has restricted internet access. One of the sites I can't access is QtCentre for some god forsaken reason. I have no way of transferring files from development computer to my computer with full (basically) internet access. They won't let me use a thumb drive, portable hard drive, burn a CD or anything else to move it over, absolutely nothing. It's ridiculous in this situation where it's QtCentre, but I don't make the rules. There's just no way to do it. I know this was kind of long and I tried to explain it clearly, but if I didn't please let me know and I'll see what I can do to make it easier to understand. Maybe if I beg and plead they'll make an exception and let me use a portable hard drive or something to move it over.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: even expansion of combobox

    You need a better job, working for someone other than the gummint.

    To prevent the comboboxes from expanding, you can set a maximum size. I don't understand why you would think setting a *minimum* width would prevent them from expanding - that just prevents them from getting any smaller than the minimum but has no effect on the maximum width. You can also add a horizontal spacer to a new right column of the grid layout, in the cell next to the combobox. That will push the comboboxes to the left.

    Be careful when setting fixed sizes, though. If the default font is changed or the user's PC has font magnification > 100%, then strings may no longer fit into the width you have determined works for *your* PC.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2014
    Location
    USA
    Posts
    85
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: even expansion of combobox

    d_stranz, I don't know if you recognize the name, but you've helped me a lot in the past and I thank you for that. Yeah, I went from one gummit contractor to another. This one is not nearly as unreasonable as the last one though. If you tell them you can't reasonably do something, I don't get "Do it anyway." This will probably be one of those cases. I don't have to worry about losing my job just because I said it can't be done within the time constraints. Thank God. Hope you had a good Christmas and if you use the Julian calendar, Happy New Year!

  4. The following user says thank you to TonyInSoMD for this useful post:

    d_stranz (1st January 2019)

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: even expansion of combobox

    Back in the day, I actually worked for the gummint, a couple of blocks from the White House. One of the things I did while I was there was to rewrite (in my spare time), a big piece of contractor-written software, which like all contractor-written software did what was specified, not what was actually needed. What I did eventually was adopted by the entire agency and earned me a special recognition award.

    I knew some of the contractors who had written the original software, and they recognized that what they were writing was hard to use crap, but like you, their hands were tied by their company and by the specifications they had to write against. I was lucky in that I had no such constraints and I could work to make lives better for the people in my own division.

    I wasn't cut out to be a gummint employee though, and moved on to better things.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QTreeView expansion after model reset
    By d_stranz in forum Qt Programming
    Replies: 3
    Last Post: 4th December 2014, 00:42
  2. Unable to get the correct QWidget width after expansion
    By sajaskk in forum Qt Programming
    Replies: 3
    Last Post: 10th June 2013, 16:49
  3. Expansion rules for a blank widget
    By dohzer in forum Newbie
    Replies: 4
    Last Post: 12th August 2010, 17:07
  4. Suppress QSettings Expansion of @ Symbol
    By ChrisW67 in forum Newbie
    Replies: 0
    Last Post: 19th April 2010, 05:03
  5. Drawing the expansion dialog widget
    By kaushal_gaurav in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2008, 10:54

Tags for this Thread

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.