i got problem here.
i'm building qt app uses slidingstackedwidgets in order slide 1 page one.
i have 2 toolbars, toptoolbar , bottomtoolbar not slide when central widget moves.
so have declared qaction in mainwindow.h
qaction *backtomainvert;
and in mainwindow.cpp, when call second view clicking button, call slideinadd() method goes this:
slidingstacked->slideinidx(1); //this takes me second page backtomainvert = this->toptoolbar->addwidget(backbarbutton); //this adds backbutton toptoolbar
now backbarbutton connected slidetomain() method which, when triggered takes me first page , removes backbarbutton toptoolbar
this->toptoolbar->removeaction(backtomainvert); slidingstacked->slideinidx(0);
the first time switch second page, no problem, button created , displayed on toptoolbar.
when click backbarbutton, goes first page.
but second time want return first page second page, backbarbutton never appears.
uh, maybe can help, here way instantiate backbarbutton :
backbarbutton = new qtoolbutton(this); backbarbutton->settext("retour"); backbarbutton->setfixedsize(80,30); backbarbutton->setstylesheet("background-image: url(:/toolbarbutton.png);" "background-repeat: no-repeat;" "background-position: center center;" "border:0;" "color : white;" "font-family: system;" "font-style: bold;" "font-size: 9pt;" "color : white;");
any idea i'm missing here please ?
thanks in advance, i'm stuck.
miky mike
hello world,
could suggest way of achieving toolbar ? wish find myself debugger inside qt doesn't give me detail. doesn't stop on breakpoint. should start ?
thanks help.
mike
ok guys,
seems way go add qaction toptoolbar in slideinadd() method.
void mainwindow::slideinadd(){ slidingstacked->setverticalmode(true); slidingstacked->slideinidx(1); backaction = new qaction(qicon(":/toolbarbutton.png"), tr("&retour"), this); toptoolbar->addaction(backaction); connect(this->backaction,signal(triggered()),this, slot(slideinmainvert())); }
and in slideinmainvert() method :
this->toptoolbar->removeaction(backaction);
it's working way problem can't figure out how customize qtoolbutton appears in toptoolbar. bigger default size (say...100x30) text on (just button actually).
could me please ?
thanks lot...
mike
i have found way !!!
ready ?
1) first create widget contain layout hold buttons :
qwidget * toolbarcontainerwidget = new qwidget(this);
2) create layout contain buttons
qhboxlayout *toolbarlayout = new qhboxlayout(toolbarcontainerwidget);
3) create backbutton :
qpushbutton *testbutton = new qpushbutton("go !",toolbarcontainerwidget); testbutton->setfixedsize(80,20); testbutton->setstylesheet("background-image: url(:/toolbarbutton.png);" "background-repeat: no-repeat;" "background-position: center center;" "border:0;" "color : white;" "font-family: system;" "font-style: bold;" "font-size: 9pt;" "color : white;");
4) add our testbutton our toolbarlayout :
toolbarlayout->addwidget(testbutton);
5) set layout toolbarcontainerwidget : (and here brain begins sweat...;-))
toolbarcontainerwidget->setlayout(toolbarlayout);
6) add widget our toolbar :
toptoolbar->addwidget(toolbarcontainerwidget);
7) connect button slideinmainvert() method :
qobject::connect(testbutton,signal(clicked()),this,slot(slideinmainvert()));
8) when slide first page, use :
toptoolbar->clear();
which clears toolbar...
uh, well, have admit it's bit complicated haven't been able find better way. if guys have suggestion, please let me know...
hope can anyway...
miky mike
Comments
Post a Comment