PDA

View Full Version : a box around QLineEdit?



GreyGeek
30th January 2006, 22:45
In Qt3.3 one could put a single pixel black line around a QLineEdit text box, instead of selecting the "frame" option, which made the QLineEdit appear as if it were in a hole.

I am not able to find such an option in the QT4 QLineEdit, nor am I able to see a way to do so using styles. It appears I can only use the "frame" setting which creates the 'hole'.

How can I draw a black line around a textbox?:confused:

KjellKod
31st January 2006, 11:07
You can always enable Qt3 support and use QLineEdit (Qt3), ref: trolltech documentation

Everall
31st January 2006, 11:51
With QT4 .1 you can set the following in designer :
QTextEdit
frameShape to QFrame::Box
frameSchadow to QFrame::Plain

this gives just a line around the QTextEdit.

If this is not what you want, can you give us a picture of what you want.

Cheers

GreyGeek
31st January 2006, 20:40
With QT4 .1 you can set the following in designer :
QTextEdit
frameShape to QFrame::Box
frameSchadow to QFrame::Plain

this gives just a line around the QTextEdit.

If this is not what you want, can you give us a picture of what you want.

Cheers
Visually it is exactly what I want.
Functionally, it's a quantum leap apart from the functionality of QLineEdit. Too many differences I'd have to configure around to be practical.:(
Thanks anyway.

Everall
1st February 2006, 09:29
Hello GreyGeek,


Visually it is exactly what I want.
Functionally, it's a quantum leap apart from the functionality of QLineEdit. Too many differences I'd have to configure around to be practical.
Thanks anyway.

Here is a quick workaround that looks like what you want and has the functionality too. It can be done without code, just using QT designer.

put a QFrame on your dialog. Set its properties :
frameShape to QFrame::Box
frameSchadow to QFrame::Plain
margin and spacing to 0

put a QLineEdit in it and apply a grid layout on it.

Hope this helps

GreyGeek
1st February 2006, 18:22
Hello GreyGeek,


Here is a quick workaround that looks like what you want and has the functionality too. It can be done without code, just using QT designer.

put a QFrame on your dialog. Set its properties :
frameShape to QFrame::Box
frameSchadow to QFrame::Plain
margin and spacing to 0

put a QLineEdit in it and apply a grid layout on it.

Hope this helps
I considered that but for over 50 QLineEdit boxes it would be impractical. Also, user demands require a textbox density so high that such a frame would not allow my app to fit in our standard 800X600 workstation desktop.
Thanks anyway.

wysota
5th February 2006, 15:55
Have you heard of "find & replace" paradigm? ;) Make a wrapper of functionality you desire and then wrap all occurences of QLineEdit into it. And BTW. What would need to be "configured" that makes you think it is not worth the effort?

GreyGeek
5th February 2006, 21:58
Hello GreyGeek,


Here is a quick workaround that looks like what you want and has the functionality too. It can be done without code, just using QT designer.

put a QFrame on your dialog. Set its properties :
frameShape to QFrame::Box
frameSchadow to QFrame::Plain
margin and spacing to 0

put a QLineEdit in it and apply a grid layout on it.

Hope this helps

Interestingly, I had ported the GUI to Linux and this weekend I opened up the GUI in the Qt-4 designer and to my suprise noticed that there is a "frame" property in the QLineEdit widget when it displays in Linux, but not when it displays in Windows. By setting the frame to "true" a line appears around the QLineEdit widget. Same ui file, so I guess the Designer is slightly different for each platform.:confused:

Everall
6th February 2006, 09:22
I think the chosen window style makes it like that.

When I use form preview plastique style, it looks like what you want, other styles don't. They have the same "hole appearance".

Cheers

GreyGeek
7th February 2006, 21:02
Have you heard of "find & replace" paradigm? ;) Make a wrapper of functionality you desire and then wrap all occurences of QLineEdit into it. And BTW. What would need to be "configured" that makes you think it is not worth the effort?

Even the other coding tools I've used also use search and replace! ;)

But, Search in what and replace what?

Here is a small part of the function which updates part of a column of QLineEdit widgets in homestead.cpp:


...
ui.leSSSN->setText(persRec.value(9).toString());
ui.lePart->setText(persRec.value(10).toString());
ui.leTotalIncome->setText(QString::number(persRec.value(11).toDouble (),'f',2));
ui.leP2Line1->setText(QString::number(persRec.value(12).toDouble (),'f',2));
ui.leP2Line2->setText(QString::number(persRec.value(13).toDouble (),'f',2));
ui.leP2Line3->setText(QString::number(persRec.value(14).toDouble (),'f',2));
ui.leP2Line4->setText(QString::number(persRec.value(15).toDouble (),'f',2));
ui.leP2Line5->setText(QString::number(persRec.value(16).toDouble (),'f',2));
ui.leP2Line6->setText(QString::number(persRec.value(17).toDouble (),'f',2));
ui.leP2Line7a->setText(QString::number(persRec.value(18).toDouble (),'f',2));
...

We're talking a tax form with several subforms so you have an idea of how many QLineEdit widgets there are on that form, each with it's own identifying name. Global S&R games aren't practical here.

Neither are arrays or array functions.

Everall
7th February 2006, 21:18
You could get all the widgets of your dialog, test them being QLineEdits and then change their properties.

Have a look at findChildren. There is an example that takes all the QPushButtons.


QList<T> QObject::findChildren ( const QString & name = QString() ) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. An empty string matches all object names. The search is performed recursively.
The following example shows how to find a list of child QWidgets of the specified parentWidget named widgetname:

QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname");
This example returns all QPushButtons that are children of parentWidget:
QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>();
Warning: This function is not available with MSVC 6. Use qFindChildren() instead if you need to support that version of the compiler.
See also findChild() and qFindChildren().

Cheers

wysota
7th February 2006, 23:32
Keep an array of pointers to QLineEdits and then:


for(int i=0;i<10;i++){
lineedits[i]>setText(QString::number(persRec.value(i+11).toDoub le(),'f',2));
}

Anyway, what is the frame property having to do with this?

GreyGeek
8th February 2006, 16:38
...
Warning: This function is not available with MSVC 6. Use qFindChildren() instead if you need to support that version of the compiler.
.....
Cheers

I'll give you one guess as to which compiler I am using...;)

GreyGeek
8th February 2006, 16:40
...
Anyway, what is the frame property having to do with this?
Nothing, except for the fact that this msg trail evolved from your suggestion to use a wrapper.:)