Sunday 15 August 2010

c++ - Derive QMainWindow and change its layout -



c++ - Derive QMainWindow and change its layout -

i have big problem customizing qmainwindow because don't know how accomplish next thing:

in qmainwindow documentation qmainwindow presented have special areas toolbars, dock widgets, status bars, , other:

now want have new , custom area new custom type of widget, example:

i tried deriving qwidget , putting custom widget up, , underneath qmainwindow using method have redirect standard qmainwindow methods qwidget qmainwindow kid inconvenient.

my question is: possible customize qmainwindow layout , add together additional area standard layout custom widget area in image above?

i've got 2 news you: bad , good.

bad news: qmainwindow uses qmainwindowlayout part of qt private headers can`t customize layout 'honestly', as-is.

but can still it. there qmainwindow::setmenuwidget method can useful you. if main window not have menu bar can write

setmenuwidget(mycustomwidget);

and mycustomwidget placed @ top of window.

however not easy if have menu bar in app. in case may still place @ top of window widget consists of 2 parts: custom widget above , menu bar below. illustration qtdesigner-generated window can done below:

mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); qlabel *coollabel = new qlabel("the coolest text in world", this); qwidget *menuwidget = new qwidget; qvboxlayout *vlayout = new qvboxlayout; menuwidget->setlayout(vlayout); vlayout->addwidget(coollabel); vlayout->addwidget(ui->menubar); setmenuwidget(menuwidget); }

c++ qt qwidget qmainwindow qlayout

No comments:

Post a Comment