PDA

View Full Version : Adding a QLineEdit to a QToolBar



sajanisch
4th March 2010, 20:21
Hi, I'm a relative newbie, have figured out quite a bit but am stuck on something that feels like it should be easy.

I want to add a LineEdit Widget to the main toolbar
It seems I can't do this in the designer :-(
So I am trying to do it programmatically

QLineEdit *txtIpAddress = new QLineEdit(ui.mainToolBar);
QAction *action = ui.mainToolBar->addWidget(txtIpAddress);
action->setVisible(true);

nothing shows up on the toolbar though

thanks, Scott

Lykurg
4th March 2010, 20:27
Your code is perfect and works for me. Check if it is "ui." (=dot) or "ui->". Depending of how you use the designer generated file in your program.

sajanisch
4th March 2010, 20:48
I'm positive that "ui." is correct for my case (I'm doing the same in dozen's of other locations)
Is there some setting in the properties window that could effect this ?

Are you on windows (me) or linux ? (shouldn't matter)

Lykurg
4th March 2010, 20:56
ok, then it is strange. I am on linux but that shouldn't have any effect. Try to make an other simple project where you only add a line edit and a normal action to the toolbar. If it works there, you have an other error in your code (somewhere else).If it don't works, send the minimal example to the forum and if it works on other non windows machines and does also not works on other windows computers, then it must be a bug in windows...

sajanisch
4th March 2010, 21:07
I did find my problem, I had the code snippet above in the wrong place and it wasn't getting called right away
So it is correct, thanks !