Hi. from the image. i would like to link the Combox with the lineEdit. as in i select End device 1, only the things in end device 1 would be change to whatever i type in the lineEdit. can anyone give me some example of code about doing it?
Printable View
Hi. from the image. i would like to link the Combox with the lineEdit. as in i select End device 1, only the things in end device 1 would be change to whatever i type in the lineEdit. can anyone give me some example of code about doing it?
connect the singnal of combobox activated() to some slot in your dialog and play with lineedit
i know the connect part. but how about the play part?
i have attach an image what..
why cant you rephrase your question?
do you whant to change the text in combobox to whatever u type in lineedit?
EDIT..
i still cant understat what is qTemp?
nope. okay i roughly explain what i am doing and what i want. first for the image there is a yellow node. they will be 8 of them. so my combobox i already set it to 8 choice. from "End Device 1 to 8"
so now lets say when i select End device 1 on my combobox, and a type a certain word in the lineEdit. when i press ok. the word in the line edit will appear on the yellow node.
nvm just know it as printf.Quote:
i still cant understat what is qTemp?
do it like this..
Code:
//main MyDialog dlg; { int deviceId = dlg.getDeviceId(); if(!word.isEmpty()) putWordInUse(word); ..... ... } //MyDialog int MyDialog::getDeviceId() { return combobox->currentIndex()+1;//0+1=end device 1 ,1+1..... } int MyDialog::getWord() { return lineEdit->text(); }
do not forget to connect the ok button to accept() slot of QDialog
i dun think this will work with my current code. argh talking in forum is pretty hard man. i cant possible post my whole source code here.
do you have a msn or something? so i could end you my whole program. and u help me take a look?
sorry man .. this is the best i can do...
oh man. i seriously need some help here. anybody?
no reply from anyone else?
I think that it is hard to give you some example because we don't know what is that yellow node. Is it some widget or what? A picture? Diagram in some other application? There are some signals in QLineEdit which you can use (like textChanged() ) so you can connect them to your slots, where you can check the current combo box selection and change proper node (yellow or any other you want). But how would I know how to change that yellow node? Paint it with QPainter or what?
That's a bad idea, because then all other board members can't learn from your problem.
We live in different time zones, so sometimes we have to sleep;)
And as to your question: It's also not very clear to me what you want to achieve: Change the yellow bubble text on the fly while typing in the line edit, or after the dialog has closed?
For the first, emit a signal from the dialog whenever the text changes. catch that in your main window and manipulate the corresponding node.
After closing the dialog use QComboBox::currentIndex() or QComboBox::currentText() to determinate the box. Either use switch or if/else unless you don't have stored your nodes in a QList etc.
okay first of all. to kickstart. i suppose i have to connect the combobox to the qlineEdit right?
i had look through the some examples and the QT Assistant. but i am still confuse of how to go about connecting it.
Come on, what's the problem QCombobox::currentIndexChanged(const QString&) -> QLineEdit::setText()! REad about signal and slot mechanism.
come on. i am very new to this QT library. i am dump to do this project for my Final Year of Diaploma. please be patience with me :D
hmm so i think your problem is quite simple:
1. You open a dialog with combo box and line edit
2. Then you edit this dialog and close it
3. After close you want to set the right bubble (yellow for example) with the right text.
Right?
If yes then:
1. If you have some custom dialog (your own subclass of QDialog) just make two methods for it: one to get the selected index and one to get the line edit text. I assume you use QDialog::exec() to open it, so after exec() just read those values and set the right bubble with right text calling your method which paints it (whith QPainter and so on).
2. If you have QDialog object and you set the ui to it (setupUi()) then you can get the values staight form ui object (Ui::SomeDialog).
faldzip. i dont know how to get the selected index of the combobox.
can i have an example of code for me try out or something.
brother... just for two minutes try to put yourself in our shoes.. first of all we still dont know what is your exact problem.. secondly you dont seem to be intrested in showing a bit your your code.. thirdly .. you dont know how to use the currentIndex...
seriously... i really doubt your exp. in programming... Did you jumped directly to Qt before learning C++ or flow charts even?? ... I dont want to be harsh.. but you would do yourself a favour if you start reading more of assistant.
or you can wait for our gurus for answers... i am out of luck...
MrDeath. yes i understand. dun doubt my programming. i got all A for my programming module for my diaploma course. i've learn c# c++ htm and mp 8051.
but the problem here is QT library. i am really totally new to it. i am dump with this project for my Final Year Project. i myself is really struggling. i had done alot of change to my GUI.
if i were to show my codes. its a whole lot of things to show =X
i did try to understant the assistant. but it didnt work. i am doing this project on my own, my only hope is you guys from forum.
really need the help. alright. so what izzit that you dun understand of my problems?
ok... the very first process of solving a problem is to isolate it from the rest of the program.
please make a very small compilable program which reproduces your problem. I will not take more than 30 min to make one..
alright. i will try doing it.
but QT is not like C#, when i create the GUI. i can program it by double clicking it.
as for QT, when i use Qt Designer. i could only create the GUI. how do i start programming it. at the very least how do i make the main.cpp to start the "project"
alright i will use the example codes to try.
thats the way to go!!
C# can only be used on windows... Qt is everywhere.. C# programs are at least 10 times slower than Qt(C++).. this is the trade off between speed and ease.Quote:
but QT is not like C#, when i create the GUI. i can program it by double clicking it.
now i uderstood your problem... so you have not yet made any program in Qt. Take my advice.. forget about Qt Designer... first try to learn how to code everything by hand written c++. Fire up Qt assistant and look for tutorial.. This is a 10-15 chapter long tutorial which will make you just about good in Qt and you will love it.Quote:
as for QT, when i use Qt Designer. i could only create the GUI. how do i start programming it. at the very least how do i make the main.cpp to start the "project"
If you are in a hurry to make your project its better to make it in C# coz you already know it... remember one thing.. we can only give hints.. nobody can program for you.. and you have at least know the basics of Qt, so that what we try to explain you is understood by you... :)
but the GUI of this project i have is programmed using Qt by Texas Instruments. so i have no choice but to program using Qt...
so better start learning now...
ya damn. if its in C# it will be much much more easier i guess. lol
and i only have 4 weeks left. -_-! i had almost complet my project. this last part is the worst. i manage to slove many of it myself. Qt.... its really nice but really hard -_-!
alright MrDeath. if this question is a yes. i might be able to make what i wan in a simple but not very professional way. lol.
can i have a QLineEdit on top of my Qpainter?
QPainter is a brush which is used to paint on a widget. A widget can have other widgets inside it. So if i understood you correctly... yes you can paint your widget and also have a lineedit on top of it somewhere.
but really brother... please at least spent a day on qt tutorial... you will be gald you did.
ahaha. yes. i am doing it right now in the Qt Assistant with the address book tutorial.
hopefully at the end of it, it will help me someways.
thanks MrDeath. haha. i will come back to you for more question. =)
our "Gurus" can give you more good answers than me :)
lol. but theres only you who reply me... lol
eh.. how do i place the position and adjust the length and width of the lineedit ontop of the painter widget?
lineedit->move(), linedit->resize()
and the "gurus" are in different timezones so just wait a while...
now dont ask anymore questions... read the tutorial and come back after two days..
Read about the layout system of Qt (QBoxLayout, QGridLayout). Don't position them fix!
and how many weeks did you have for the project? maybe you should start doing it earlier :]
And I don't see why Qt is hard? Because it's C++ library? Then it means that C++ is hard for you (for me it is not so hard). Qt has a really good documentation, a lot of examples and everything. I have my assistant open almost everytime I code with Qt just to check the right metods, signals and such things.
And how many years are you studying? I had different programming languages on my studies, and I use C++ but I think that general idea is similar in C# and Java so if you know C# then doing something in C++ shouldn't be a big problem. And Qt is just a bunch of C++ classes (plus some tools).
LOL yellow bubble thread -_-!
i left with 3 more weeks. i only had 12 weeks to do this. like i said, i had already done much changes to my project already. left with this name thing.Quote:
and how many weeks did you have for the project? maybe you should start doing it earlier :]
hmm. i dun know why, but it just look abit hard to understand, even with the assistant, haha. like i say again, i am totally new to this Qt open source.Quote:
And I don't see why Qt is hard? Because it's C++ library? Then it means that C++ is hard for you (for me it is not so hard). Qt has a really good documentation, a lot of examples and everything. I have my assistant open almost everytime I code with Qt just to check the right metods, signals and such things.
3 years of engineering, this is my final year. hehe. hmm. perhaps i don understand and dun know how to apply the classes of the Qt source i guess. and for this project. there is alot of .cpp in it. maybe that is why it making me more hard to cope with. as whatever i learnt in my 2 years, i only counter with 1 .cpp, all the programming is done in that 1 .cpp including the declaration.Quote:
And how many years are you studying? I had different programming languages on my studies, and I use C++ but I think that general idea is similar in C# and Java so if you know C# then doing something in C++ shouldn't be a big problem. And Qt is just a bunch of C++ classes (plus some tools).
nvm. i will work harder, its an exposure for me doing this final year project. i love programming. haha.
you have to pass the parent to lineedit
new QLineEdit(this);