c++ - Qt Attach a dynamic button to a window -
so want create following: when button pushed, create button @ point x size y has text extracted textedit. function have made:
void mainwindow::on_pushbutton_released() { qstring = ui->textedit->toplaintext(); qpushbutton* ptr = new qpushbutton(a); addwidget(ptr); // figured should utilize function, thing don't know should phone call ptr->show(); ptr->setgeometry(260, 140, 40, 40); }
it works, window appears on 260, 140 on desktop. want 260,140 in main window, wherever is. in advance.
you should give qpushbutton
parent, @ wich lie. utilize next qpushbutton's constructor:
qpushbutton ( const qstring & text, qwidget * parent = 0 );
code this:
void mainwindow::on_pushbutton_released() { qstring = ui->textedit->toplaintext(); qpushbutton* ptr = new qpushbutton( a, /* <------------ */ ); ptr->show(); ptr->setgeometry(260, 140, 40, 40); }
c++ qt
No comments:
Post a Comment