1

Topic: Operation with QGridLayout

Good morning, left a question in the previous topic, probably nobody knows, therefore decided to make : I want to allocate over one of cells new : int x, y, w, h; _sectionsGridLayout-> itemAt (i)-> widget ()-> geometry ().getRect (&x,&y,&w,&h); _widget = new QWidget (this); QHBoxLayout* HBLayout = new QHBoxLayout; QPushButton* pb = new QPushButton ("1111111111"); HBLayout-> addWidget (pb); _widget-> setLayout (HBLayout); _widget-> geometry ().setRect (x, y, w, h); but me Qt produces an error: error C2662: ' void QRect:: setTopLeft (const QPoint) noexcept ': cannot convert ' this ' pointer from ' const QRect ' to ' QRect and ' searched in an Internet, there something about cons_cast write, tried to implement so: const_cast <QRibbonTab *> (this)-> _widget-> geometry ().setRect (x, y, w, h); the error is not left, what I do not so?

2

Re: Operation with QGridLayout

Hello, TOPAZ23, you wrote: TOP> Good morning, left a question in the previous topic, probably nobody knows, therefore decided to make : TOP>... TOP> the error is not left, what I do not so? The following not so: TOP> TOP> _widget-> geometry ().setRect (x, y, w, h); TOP> At you explicitly problem with programming essentials. The decision. On the future - attentively read that do methods which you use. geometry () returns the constant link on QRect (current geometry of a window). And even if you through const_cast manage to change this value it does not mean that at you something earns (and, most likely, falls off, for const_cast is a shot in a foot). Because setGeometry does still something, besides depositing of values in a variable.