Weirdest Qt Layout "flesh eating" problem -
Weirdest Qt Layout "flesh eating" problem -
i'm writing own class, similar toolbar, contain widgets under horizontal box layout object within of it.
i have widget class serving container have widget class deriving qpushbutton, custom painting (really showing loaded image @ pos 0,0).
i initialize layout object:
this->buttonlayout = new qhboxlayout(this); this->buttonlayout->setcontentsmargins(0, 0, 0, 0); this->buttonlayout->setspacing(0); this->buttonlayout->setobjectname("buttonslayout"); and start initializing widgets , "adding" them onto layout similar this:
// 1 time button created.. add together it... this->buttonlayout->addwidget(button); in end, create spacer object create sure toolbar buttons aligned left.
qspaceritem * spaceritem = new qspaceritem(0, 0, qsizepolicy::expanding, qsizepolicy::expanding); this->buttonlayout->additem(spaceritem); my button class defining "setminimumsize" in constructor right under debugger. it's redefining "hintsize" called during runtime , values correct.
my problem this. load 3 "buttons" onto toolbar. have variable sizes. if spacing on layout 0 first 2 buttons truncated 9 pixels exactly!, 3rd 1 okay. if layout spacing -1 buttons show nicely variable size, have 2 pixel space between them (i don't want space). lastly, if layout spacing "9", show fine.
why spacing "0" messing button layout causing overlay? did number "9" come from? why first 2 buttons (e.g. lastly button) truncated 9 pixels when spacing "0"?
i couldn't find reply anywhere.
additional info:
i've narrowed downwards this:
for every button class, load qimage. hintsize returns size, it's right under debugger. returned size matches photoshop says image, , properties of image it...
however, on toolbar, after layout, given width "- 9" !!! next button right painted on it, hiding 9 x height pixels of button left.
if manually add together "+9" sizehint in button class, works perfectly.
i can't understand problem comes from. somewhere between layout , horizontal spacer, pixels "stolen" , don't know heck's going on here.
has encountered that? why have "pre-steal" 9 pixels each button layout perfect?
solution:
this appears knows qt problem under osx. note next bug report: http://bugreports.qt-project.org/browse/qtbug-14591
resolution:
by setting qt::wa_layoutuseswidgetrect attribute each button.
qt
Comments
Post a Comment