Have a following code:
Class MainWindow
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
MainScreem *mainScreem = new MainScreem();
ui->scrollPrueba->setWidget(mainScreem);
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
MainScreem *mainScreem = new MainScreem();
ui->scrollPrueba->setWidget(mainScreem);
}
To copy to clipboard, switch view to plain text mode
Class MainScreem
{
vLayout->addWidget(listWidget);
for(int i=0; i<5;i++)
{
item
->setText
(QObject::tr("List Item: %1").
arg(i
));
listWidget->addItem(item);
}
}
{
DetailScreem *detail = new DetailScreem();
delete this->layout();
vLayout2->addWidget(detail);
}
MainScreem::MainScreem(QWidget *parent) : QWidget(parent)
{
QVBoxLayout *vLayout = new QVBoxLayout(this);
QListWidget *listWidget = new QListWidget();
vLayout->addWidget(listWidget);
QObject::connect(listWidget, SIGNAL(itemClicked(QListWidgetItem*)), this,
SLOT(detailSlot(QListWidgetItem*)));
for(int i=0; i<5;i++)
{
QListWidgetItem *item = new QListWidgetItem();
item->setText(QObject::tr("List Item: %1").arg(i));
listWidget->addItem(item);
}
}
void MainScreem::detailSlot(QListWidgetItem *item)
{
DetailScreem *detail = new DetailScreem();
delete this->layout();
QVBoxLayout *vLayout2 = new QVBoxLayout(this);
vLayout2->addWidget(detail);
}
To copy to clipboard, switch view to plain text mode
Class DetailScreem
{
vLayout->addWidget(label);
}
DetailScreem::DetailScreem(QWidget *parent) : QWidget(parent)
{
QVBoxLayout *vLayout = new QVBoxLayout(this);
QLabel *label = new QLabel("Hola Mundo");
vLayout->addWidget(label);
}
To copy to clipboard, switch view to plain text mode
My problem is that the MainScreem widget is behind the DetailsScreem widget. That is, the scrollPrueba not replace or not updated, seeing two widgets one after the other.
If someone could help me with this problem so that the DetailsWidget is drawn but the MainScreem widget does not appear ago.
I appreciate the cooperation.
Thank you very much.
Bookmarks