Hi,

I'm having issues with a Label which is located on a QWigdet which has a
gradient background. When the wiget changes the text the background is
not transparent any more until I resize the window.

I guess I need to call a method after the text has been set but I can't
find the right one I guess.

> package org.ufacekit.ui.qt.example;
> 
> import com.trolltech.qt.gui.QApplication;
> import com.trolltech.qt.gui.QBrush;
> import com.trolltech.qt.gui.QColor;
> import com.trolltech.qt.gui.QGridLayout;
> import com.trolltech.qt.gui.QLabel;
> import com.trolltech.qt.gui.QLinearGradient;
> import com.trolltech.qt.gui.QMainWindow;
> import com.trolltech.qt.gui.QPaintEvent;
> import com.trolltech.qt.gui.QPainter;
> import com.trolltech.qt.gui.QPushButton;
> import com.trolltech.qt.gui.QWidget;
> 
> public class QTGradientTest extends QMainWindow {
>       QLabel label;
>       
>       public QTGradientTest() {
>               QWidget widget = new QWidget();
>               QGridLayout layout = new QGridLayout();
>               label = new QLabel();
>               label.setText("Here");
>               layout.addWidget(label);
>               
>               QPushButton button = new QPushButton();
>               button.setText("Change");
>               button.clicked.connect(this, "clicked()");
>               layout.addWidget(button);
>               
>               widget.setLayout(layout);
>               
>               setCentralWidget(widget);       
>       }
>       
>       private void clicked() {
>               label.setText("Hello World!");
>       }
> 
>       @Override
>       protected void paintEvent(QPaintEvent evt) {
>               QPainter painter = new QPainter(this);
>               
>               QLinearGradient gradient = new 
> QLinearGradient(0,0,0,evt.rect().height() / 2);
>               gradient.setColorAt(0, new QColor(255,0,0));
>               gradient.setColorAt(1, new QColor(0,255,0));
>               
>               QBrush brush = new QBrush(gradient);
>               
>               painter.fillRect(evt.rect(), brush);
>               
>               painter.end();
>       }
> 
> 
> 
>       /**
>        * @param args
>        */
>       public static void main(final String[] args) {
>               try {
>                       QApplication.initialize(args);
>                       new QTGradientTest().show();
>                       QApplication.exec();
>               } catch (Exception e) {
>                       e.printStackTrace();
>               }
> 
>       }
> }


Tom

<<inline: screen.tiff>>

_______________________________________________
Qt-jambi-interest mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest

Reply via email to