Hi,

I'm haveing multiple problems when useing QWidget#setStylesheet().

1. Setting gradient on container is repeated in child controls

-------------8<-------------
package org.eclipse.ufacekit.ui.qt.example;

import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QGridLayout;
import com.trolltech.qt.gui.QLabel;
import com.trolltech.qt.gui.QMainWindow;
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();
                widget.setStyleSheet("background-color: qlineargradient(x1: 0, 
y1: 0,
x2: 0, y2: 1, stop: 0 #FF0000, stop: 1 #00FF00)");
                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!");
        }

        /**
         * @param args
         */
        public static void main(final String[] args) {
                try {
                        QApplication.initialize(args);
                        new QTGradientTest().show();
                        QApplication.exec();
                } catch (Exception e) {
                        e.printStackTrace();
                }

        }
}
-------------8<-------------

Results in the following output in gradient.tiff. I think I'm doing
something wrong.

2. Setting background to controls with a scrollbar for example a QList
results in an unusable Scrollbar.

-------------8<-------------
package org.eclipse.ufacekit.ui.qt.example;

import java.util.ArrayList;

import com.trolltech.qt.gui.QApplication;
import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QGridLayout;
import com.trolltech.qt.gui.QListWidget;

public class QTListStyle extends QDialog {
        private static ArrayList<String> VALUES_1 = new ArrayList<String>();
        
        {
                VALUES_1.add("Tyrol"); //$NON-NLS-1$
                VALUES_1.add("Vorarlberg"); //$NON-NLS-1$
                VALUES_1.add("Salzburg"); //$NON-NLS-1$
                VALUES_1.add("Upper Austria"); //$NON-NLS-1$
                VALUES_1.add("Carinthia"); //$NON-NLS-1$
                VALUES_1.add("Styria"); //$NON-NLS-1$
                VALUES_1.add("Lower Austria"); //$NON-NLS-1$
                VALUES_1.add("Vienna"); //$NON-NLS-1$
                VALUES_1.add("Burgenland"); //$NON-NLS-1$
        }
        
        public QTListStyle() {
                QGridLayout layout = new QGridLayout();
                QListWidget widget = new QListWidget();
                widget.setStyleSheet("background-color: #FFFF00;");
                widget.addItems(VALUES_1);
                
                layout.addWidget(widget);

                setLayout(layout);
        }
        

        /**
         * @param args
         */
        public static void main(final String[] args) {
                QApplication.initialize(args);
                new QTListStyle().show();
                QApplication.exec();

        }
}
-------------8<-------------

Thanks for any pointers.

Tom

<<inline: gradient.tiff>>

<<inline: bgcolor.tiff>>

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

Reply via email to