c++ - Qt QWidget::setGeomerty -
i'm stuck simple function of qt not work me.i made class inherits qmainwindow , class inherits qwidget.then made second member object(a pointer to) inside first , assigned centralwidget during construction of window.
when comes adjust centrawidget inside window function qwidget::setgeomerty() don't work.here's code:
void mainwindow::show() { //some code centers window on screen int margin=this->width()/7; centralwidget()->setgeometry(margin,centralwidget()->geometry().top(),this->width()-margin,centralwidget()->geometry().bottom()); qmainwindow::show(); }
i know might stupid can't figure out.help me.
qmainwindow
has own layout in center area occupied central widget. won't pretty straightforward break layout , modify central widget size / position arbitrarily. recommend use placeholder central widget , add widget child. i'm pretty sure can achieve want setting proper qt built in layout "placeholder" central widget , adding widget layout.
Comments
Post a Comment