Qt-jambi-interest Archive, August 2006
QCheckListItem
Message 1 in thread
Hello!
When will this class appear in Jambi? Anyone which can let me in on when
the next technology preview will appear for download?
Best reaards,
Helge Fredriksen
Message 2 in thread
Helge Fredriksen wrote:
> Hello!
>
> When will this class appear in Jambi?
Hi Helge,
The class you are referring to belongs to the Qt 3 support library. We
made the decision to not provide the Qt 3 support classes in Jambi since
all their functionallity is present in Qt 4 what we feel is better and
more powerful API's.
You can use QListWidgetItem as a replacement or make use of the more
powerful modelview classes with QListView.
> Anyone which can let me in on when
> the next technology preview will appear for download?
Trolltech normally doesn't go out with these kinds of dates, but its not
far away ;-)
-
Gunnar
Message 3 in thread
Helge Fredriksen wrote:
> Hello!
>
> When will this class appear in Jambi? Anyone which can let me in on
> when the next technology preview will appear for download?
>
> Best reaards,
> Helge Fredriksen
>
>
>
OK, I see now that I looked in the 3.3 class reference. Sorry about
that. Why did you remove this class? Pretty nifty I think? One more
question: I'm experimenting a bit with your
QTableView/QAbstractTableModel. Why isn't this code showing me anything
in table:
public class VoiceMessageIssueDialog extends QDialog {
public VoiceMessageIssueDialog(QWidget parent) {
super(parent);
try {
QVBoxLayout layout = new QVBoxLayout();
QScrollArea scroller = new QScrollArea();
QTableView tableView = new QTableView();
QAbstractTableModel model = new QAbstractTableModel() {
public int columnCount() {
return 2;
}
public int rowCount() {
return 2;
}
public Object data(QModelIndex qModelIndex) {
return qModelIndex.row() + qModelIndex.column();
}
};
tableView.setModel(model);
tableView.setVisible(true);
scroller.setWidget(tableView);
QPushButton transmitButton = new QPushButton("Start transmit");
layout.addWidget(scroller, 1);
layout.addWidget(transmitButton);
this.setLayout(layout);
} catch (Exception e) {
Diagnosis.diagnose(e);
}
}
public static void main(String[] args) {
QApplication.initialize(args);
VoiceMessageIssueDialog voiceMessageIssueDialog = new
VoiceMessageIssueDialog(null);
voiceMessageIssueDialog.show();
voiceMessageIssueDialog.exec();
}
}
Message 4 in thread
Helge Fredriksen wrote:
> OK, I see now that I looked in the 3.3 class reference. Sorry about
> that. Why did you remove this class? Pretty nifty I think?
Hi Helge,
This class is not model/view/controller based as the new classes are. In
addition there is identical functionallity in the class I referred to,
QListWidgetItem.
One more
> question: I'm experimenting a bit with your
> QTableView/QAbstractTableModel. Why isn't this code showing me anything
> in table:
You're not overriding the proper virtual functions ;-)
<snip>
QAbstractTableModel model = new QAbstractTableModel() {
public int columnCount(QModelIndex index) {
return 2;
}
public int rowCount(QModelIndex index) {
return 2;
}
public Object data(QModelIndex qModelIndex, int role) {
if (role == Qt.DisplayRole)
return qModelIndex.row() + qModelIndex.column();
return super.data(qModelIndex, role);
}
};
</snip>
If you read the documentation for QAbstractTableModel you see which
functions you need to override.
http://doc.trolltech.com/4.1/qabstractitemmodel.html
-
The main problem here is that these functions have default arguments
which is supported only through overloaded functions. These overloaded
functions currently have mostly the same attributes as the original
function. I'll see if we can't make those final so that this kind if
mistake won't happen.
-
Gunnar
Message 5 in thread
>
> One more
>> question: I'm experimenting a bit with your
>> QTableView/QAbstractTableModel. Why isn't this code showing me
>> anything in table:
>
> You're not overriding the proper virtual functions ;-)
> If you read the documentation for QAbstractTableModel you see which
> functions you need to override.
Hmm, this is really strange. I tried to override your data() method +
also the parent() method which was
suggested in the documentation you sent me. I also tries to put
breakpoints inside the code in each method
in the class to see if it get any calls into it, but nothing happens.
Seems like there is some kind of initialization
of the tableView/tableModel that is missing.
Shouldn't it be enough to say
<snip>
tableView.setModel(model);
</snip>
?? Anyway the problem with overriding the wrong method is best solved by
making the correct methods
abstract, so the coder gets immediate feedbacks (from the editor
preferably like in IntelliJ) that thing's are
incorrect.
Regards,
Helge Fredriksen
Message 6 in thread
Helge Fredriksen wrote:
> Hmm, this is really strange. I tried to override your data() method +
> also the parent() method which was
> suggested in the documentation you sent me. I also tries to put
> breakpoints inside the code in each method
> in the class to see if it get any calls into it, but nothing happens.
> Seems like there is some kind of initialization
> of the tableView/tableModel that is missing.
Did my example work or not? It ran fine for me when I tested it against
the tp1 package.
The docs say to override:
int rowCount(const QModelIndex &parent = QModelIndex()) const
int columnCount (const QModelIndex &parent = QModelIndex()) const
QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const
which translated to Java becomes:
public int rowCount(QModelIndex parent);
public int columnCount(QModelIndex parent);
public Object data(QModelIndex parent, int role);
I realize that this is not straightforward, so we're working on
improvements. Also with providing JavaDoc so that browsing this
documentation with the proper signatures becomes easier.
> ?? Anyway the problem with overriding the wrong method is best solved
> by making the correct methods abstract, so the coder gets immediate
feedbacks (from the editor
> preferably like in IntelliJ) that thing's are incorrect.
That is already fixed for the upcoming tech preview.
-
Gunnar
Message 7 in thread
Gunnar Sletta wrote:
> Did my example work or not? It ran fine for me when I tested it
> against the tp1 package.
No, I'm just getting an emptly white box in the place where I would
expect a table with 2 rows
and 2 columns as expressed in the model. Here's my complete code. What
is the tp1 package?
public class VoiceMessageIssueDialog extends QDialog {
public VoiceMessageIssueDialog(QWidget parent) {
super(parent);
try {
QVBoxLayout layout = new QVBoxLayout();
QScrollArea scroller = new QScrollArea();
QTableView tableView = new QTableView();
QAbstractTableModel model = new QAbstractTableModel() {
public QModelIndex index(int i, int i1) {
return createIndex(i, i1);
}
public int columnCount() {
return 2;
}
public int rowCount() {
return 2;
}
public Object data(QModelIndex qModelIndex, int role) {
if (role == Qt.DisplayRole)
return qModelIndex.row() + qModelIndex.column();
else
return super.data(qModelIndex, role);
}
public QModelIndex parent(QModelIndex qModelIndex) {
return null;
}
};
tableView.setModel(model);
QTableWidget tableWidget = new QTableWidget();
for (int i=0; i<3; i++) {
}
scroller.setWidget(tableView);
QPushButton transmitButton = new QPushButton("Start transmit");
transmitButton.clicked.connect(this, "startTransmit()");
layout.addWidget(scroller, 1);
layout.addWidget(transmitButton);
this.setLayout(layout);
} catch (Exception e) {
Diagnosis.diagnose(e);
}
}
private void startTransmit() {
// Do your funky stuff...
}
public static void main(String[] args) {
QApplication.initialize(args);
VoiceMessageIssueDialog voiceMessageIssueDialog = new
VoiceMessageIssueDialog(null);
voiceMessageIssueDialog.show();
voiceMessageIssueDialog.exec();
}
}
> I realize that this is not straightforward, so we're working on
> improvements. Also with providing JavaDoc so that browsing this
> documentation with the proper signatures becomes easier.
>
Great!!
> That is already fixed for the upcoming tech preview.
Yuhu, I'm really looking forward to it!
One more thing I have seen when working with the Jambi GUI toolkit. It
would be Really Nice if there could
be some kind of GuiSignal class which could ease the transfer of
signals from off-GUI threads to processing
in the GUI thread. For instance, if you do myThreadSignal.emit("Howdy"),
and having the statusbar
component connected to this signal, it would crash the whole VM. Not
very nice, I think. Maybe I could
solve this myself with some ingenious code, but I haven't figured
anything out yet...
Regards,
Helge Fredriksen
Message 8 in thread
Helge Fredriksen wrote:
> Gunnar Sletta wrote:
>
>> Did my example work or not? It ran fine for me when I tested it
>> against the tp1 package.
>
> No, I'm just getting an emptly white box in the place where I would
> expect a table with 2 rows
> and 2 columns as expressed in the model. Here's my complete code. What
> is the tp1 package?
tp1 == Tech Preview 1 ;-)
As I pointed out in the previous mail, you're overriding the wrong
functions. You should have used the ones I had in the snip. I've
attached the full source this time.
Your columnCount() and rowCount() need to take a QModelIndex too.
> One more thing I have seen when working with the Jambi GUI toolkit.
> It would be Really Nice if there could be some kind of GuiSignal
> class which could ease the transfer of signals from off-GUI threads
> to processing in the GUI thread.
As I mentioned before, we have this one our list of things to
investigate. However, using a queued connection is the nicer
alternative. See the attached Test.java example.
> For instance, if you do
> myThreadSignal.emit("Howdy"), and having the statusbar component
> connected to this signal, it would crash the whole VM.
It shouldn't, I'll investigate. Any vm crash is considered a critical
bug, so we are fixing those as fast as we can.
Hope this helps,
Gunnar
import com.trolltech.qt.*;
import com.trolltech.qt.*;
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
public class TableModel extends QDialog {
public TableModel(QWidget parent) {
super(parent);
try {
QVBoxLayout layout = new QVBoxLayout();
QScrollArea scroller = new QScrollArea();
QTableView tableView = new QTableView();
QAbstractTableModel model = new QAbstractTableModel() {
public int columnCount(QModelIndex index) {
return 2;
}
public int rowCount(QModelIndex index) {
return 2;
}
public Object data(QModelIndex qModelIndex, int role) {
if (role == Qt.DisplayRole)
return qModelIndex.row() + qModelIndex.column();
return super.data(qModelIndex, role);
}
};
tableView.setModel(model);
tableView.setVisible(true);
scroller.setWidget(tableView);
QPushButton transmitButton = new QPushButton("Start transmit");
layout.addWidget(scroller, 1);
layout.addWidget(transmitButton);
this.setLayout(layout);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
QApplication.initialize(args);
TableModel dialog = new TableModel(null);
dialog.show();
dialog.exec();
}
}
import com.trolltech.qt.*;
import com.trolltech.qt.*;
import com.trolltech.qt.core.*;
import com.trolltech.qt.gui.*;
public class Test
{
public static QLabel label;
public static class Updater extends QObject {
public Signal1<String> update = new Signal1<String>();
};
public static void main(String args[]) {
QApplication.initialize(args);
label = new QLabel();
label.setGeometry(100, 100, 200, 40);
label.show();
label.setFont(new QFont("Times", 20));
label.setAlignment(Qt.AlignCenter);
new Thread() {
public void run() {
Updater u = new Updater();
u.update.connect(label, "setText(String)");
for (int i=0; i<10; ++i) {
u.update.emit(new Integer(i).toString());
try { Thread.sleep(500); } catch (Exception e) { };
}
QApplication.quit();
}
}.start();
QApplication.exec();
}
}