[Qt-interest] QLabel is invisible after setText()

Bruno Colombet Bruno.Colombet at univmed.fr
Fri Jan 28 12:24:39 CET 2011


I have a strange behavior problem since yesterday as I decided to 
implement a kind of "PleaseWait" Widget.

It's a very simple Widget with a QLabel centered to display messages 
during long calculations for example.

I designed the UI quickly with Qt Designer and choose multi-heritance 
for code generation.

Here is the class :

#ifndef PLEASEWAIT_WIDGET_H
#define PLEASEWAIT_WIDGET_H

#include <QWidget>
#include "ui_pleasewait_widget.h"

using namespace Ui;

class PleaseWaitWidget : public QWidget, public PleaseWaitWidgetClass
{
     Q_OBJECT

public:
     PleaseWaitWidget(const QString& message, QWidget *parent = 0);
     ~PleaseWaitWidget();
     void setMessage(const QString& message) { 
labelText->setText(message); }
private:
     QString m_message;
};

#endif // PLEASEWAIT_WIDGET_H

and the implementation :
#include "pleasewait_widget.h"

PleaseWaitWidget::PleaseWaitWidget(const QString& message, QWidget *parent)
     : QWidget(parent)
{
     setupUi(this);
     m_message = message;
     labelText->setText(m_message);
     show();
}

PleaseWaitWidget::~PleaseWaitWidget()
{
     hide();
}


I call it that way in my application :

void someMethod()
{
     PleaseWaitWidget wait(QString("Wait for me"));

     ...
     ...

     // End of calculation and end of method
}


The widget appears and disappears but QLabel still shows nothing.

When I test the UI in Qt Designer it is ok and I can see the text in QLabel.

Any ideas?
-- 
Bruno Colombet
*INSERM UMR 751* - Epilepsie et Cognition
Faculté de Médecine
27 Bd Jean Moulin
13385 Marseille cedex 05
+33 4 91 38 55 40
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110128/b774b6fc/attachment.html 


More information about the Qt-interest-old mailing list