I want to click a button and insert another page into the toolBox, but I am a beginner in Qt.
I have a main function:
void MainWindow::addPage(){
//Insert Page
}
In which I would like to call in my clicked() function.
void MainWindow::on_pushButton_2_clicked()
{
addPage();
}
Is it possible to add a page to the top of the tool box?
Any help would be greatly appreciated, thanks
Use addItem()
method
void MainWindow::on_pushButton_2_clicked()
{
ui->toolBox->addItem(new QLabel("new Label"),"example");//you can put here another widgets instead of QLabel
}
or
void MainWindow::addPage()
{
ui->toolBox->addItem(new QLabel("new Label"),"example");
}
Edit
Because you use it incorrect, constructor of QTextBrowser don't take QString (you can set only parent) Doc
If you want set text to textBrowser use something like this:
QTextBrowser *brow = new QTextBrowser;
brow->setText("foo");
ui->toolBox->addItem(brow,"example");