PDA

View Full Version : Update GUI



migel
4th July 2011, 12:23
How to update a gui information correctly on. Weird things are happening on mac, when I update label or any of widget info. The best explanation is the screenshots attached.

You can see a QDockWidget widget containing Qlabel for pixmap and QLabel for name and QTabWidget below.

Some times when the text label is shorter you can see it behind the current text.

In the example on screenshot you can see old QTabWidget behind the new one.

How to fix it, tried update() things already ....

That does not happening on linux.

Thanks6627

boudie
4th July 2011, 15:27
You have to use layouts.

migel
4th July 2011, 15:35
what do you mean

of course I do use layout (QVBoxLayout) for QDockWidget, that's how I add Qlabel = image, QLabel - name and QTabWidget.

Could you write more details what you have on your mind please ? thanks

ChrisW67
5th July 2011, 02:18
Layouts will not allow overlapping widgets, which is what seems to be happening with your progress bar. Can you show the code that constructs the dock widget layout?

migel
5th July 2011, 09:43
void MainView::createDock() {
DEBUGME;
lb_dockIcon = new QLabel;
lb_dockIcon->setMaximumHeight(60);
lb_dockIcon->setMinimumHeight(60);

lb_dockIcon->setAlignment(Qt::AlignCenter);
lb_dockLabel = new QLabel;
lb_dockLabel->setAlignment(Qt::AlignCenter);

_dockTabs = new QTabWidget;

_dockMainWidgetLayout = new QVBoxLayout;

_dockMainWidget = new QWidget;
_dockMainWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
_dockMainWidget->setLayout(_dockMainWidgetLayout);

_dockWidget = new QDockWidget;
_dockWidget->setContentsMargins(5,0,5,0);
_dockWidget->setWidget(_dockMainWidget);

connect(_dockWidget, SIGNAL(visibilityChanged(bool)), this, SLOT(showDock(bool)));

_dockMainWidgetLayout->addWidget(lb_dockIcon, Qt::AlignCenter);
_dockMainWidgetLayout->addWidget(lb_dockLabel);
_dockMainWidgetLayout->addWidget(_dockTabs);

_dockMainWidgetLayout->setStretchFactor(lb_dockIcon,0);
_dockMainWidgetLayout->setStretchFactor(lb_dockLabel,0);
_dockMainWidgetLayout->setStretchFactor(_dockTabs,1);

}

and this is how I call it to print different data again


void MainView::setDockData(IFile *file, bool) {

DEBUGME;

QPixmap icon(file->FilePixmap());

lb_dockIcon->setPixmap(icon);
lb_dockIcon->updateGeometry();

QString name = file->FileName();
FileWidget::wordWrap(name, 100, 25);
lb_dockLabel->setText(name);
lb_dockLabel->updateGeometry();

_dockTabs->clear();
_dockTabs->show();

DockVersions *versions = new DockVersions(this, file);

DockAddIn *addIn = new DockAddIn(this, file);
connect(addIn, SIGNAL(setDockTabTitle(int, QString)), this, SLOT(setDockTabTitle(int, QString)));

for(int i = 0;i < _dockTabs->count();i++) {
_dockTabs->removeTab(i);
}

_dockTabs->addTab(addIn, addIn->windowTitle());
_dockTabs->addTab(versions, versions->windowTitle());

versions->display();
addIn->display();


}

thanks for looking

migel
5th July 2011, 16:38
any ideas ??

ChrisW67
6th July 2011, 01:29
You have not applied a layout to _dockWidget, only to to the dockMainWidget widget you place inside it.