PDA

View Full Version : Input text to be listed in listWidget?



csanyipal
18th September 2016, 18:07
Hi,

I'm developing a GUI with Qt Designer version 4.8.6 on Gentoo Linux.
I can't attach it's .ui file because it is to big:
The following errors occurred:
Win2008Serv_MPS3_DealOutCollect_001.ui: Your file of 49.7 KB bytes exceeds the forum's limit of 19.5 KB for this filetype.
12109
My question follows.
Can I input text into 'Input names of Classes' that is lineEdit widget so so the entered names appeares immediately in the 'The entered names of Classes listed:' listWidget?
Or maybe there is another way to input names and get listed?

Best, Pal

anda_skoa
18th September 2016, 23:01
You can easily connect the line edit's editingFinished() signal to a slot in your form class and then call the list widget's addItem() method with the text that is currently in the line edit.

Cheers,
_

csanyipal
19th September 2016, 06:33
When in Edit Signals/Slots mode drag with mouse lineEdit to listWidget, then in Configure Connection dialog select editingFinished() signal from lineEdit, at right I have no addItem() slot at all.
I can not understand your sentence: 'to a slot in your form class'. I can't find it on my GUI..

anda_skoa
19th September 2016, 08:29
QListWidget::addItem() is not a slot, also QLineEdit::editingFinishied() doesn't have any arguments, so even if addItem() where a slot it wouldn't match argument-wise.

In any case this is a signal/slot connection that requires code, i.e. the slot needs to be implemented in the class that uses the form's generated code.

How did you start with the form? Did you use "New Form Class" in QtCreator?

That should have created three files: a header, a C++ source file and them form's ui file.
Your slot needs to be declared in the header and the body implemented in the C++ source file.
The connection can be made in code in the constructor of that class after the form's components have been initialized.

Cheers,
_

csanyipal
19th September 2016, 13:11
How did you start with the form? Did you use "New Form Class" in QtCreator?
I used New Form / Main Window form:
12114

anda_skoa
20th September 2016, 07:02
[QUOTE=csanyipal;293770]I used New Form / Main Window form:
Well, yes, that's in Designer.

How did you launch it? Manually? From QtCreator?

If you launched it manually, did you also create your project manually?
If so, which files does that currently consist of?

Cheers,
_

csanyipal
20th September 2016, 09:35
[QUOTE=csanyipal;293770]I used New Form / Main Window form:
Well, yes, that's in Designer.

How did you launch it? Manually? From QtCreator?

If you launched it manually, did you also create your project manually?
If so, which files does that currently consist of?

Cheers,
_

Yes, I'm using Qt Designer.
I launched it manually.
I have not created project so far.
I started this project with designing GUI yet.

But now I heared from you for Qt-creator. It is being installing now on my Gentoo system.

So, probably I shall use Qt Creator to create this project again.

Any advices will be appreciated!