0

So I have a scrollBar and a plainTextEdit in a window automatically created. I want the text of plainTextEdit automatically changes when the value of the scrollBar is changed. This should be some easy stuff: just add a method to MainWindow to be the "slot" which receive signal from the scrollBar.

However in Eclipse "Qt Signal Slot Editor" I cannot find the method I added to MainWindow. What is the proper way to do that?

import com.trolltech.qt.gui.*;

public class MainWindow extends QMainWindow{

    Ui_MainWindow ui = new Ui_MainWindow();

    public static void main(String[] args) {
        QApplication.initialize(args);

        MainWindow testMainWindow = new MainWindow();
        testMainWindow.show();

        QApplication.exec();
    }

    public MainWindow() {
        ui.setupUi(this);
    }

    public MainWindow(QWidget parent) {
        super(parent);
        ui.setupUi(this);
    }
    public void test(Integer t) {
        //this is the slot
    }
}
aaronqli
  • 790
  • 9
  • 26

1 Answers1

2
QPushButton myButton = new QPushButton( tr("MyButton") );

myButton.clicked.connect(this,"sayHelloSlot()");

something like this, clicked is a signal, in your case it is may be sliderMoved or rangeChanged

Nurlan
  • 673
  • 4
  • 18
  • Thanks. I have found a solution: create a class inside MainWindow, put my method in, and manually connect scrollBar to it. Jambi Eclipse Integration can't do much about it. – aaronqli Mar 19 '12 at 09:00