Results 1 to 14 of 14

Thread: a box around QLineEdit?

  1. #1
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default a box around QLineEdit?

    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?
    Last edited by GreyGeek; 30th January 2006 at 22:53.

  2. #2
    Join Date
    Jan 2006
    Location
    Scandinavia
    Posts
    62
    Thanks
    5
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    You can always enable Qt3 support and use QLineEdit (Qt3), ref: trolltech documentation

  3. #3
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: a box around QLineEdit?

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    Quote Originally Posted by Everall
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: a box around QLineEdit?

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    Quote Originally Posted by Everall
    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.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: a box around QLineEdit?

    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?
    Last edited by wysota; 5th February 2006 at 15:58.

  8. #8
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: a box around QLineEdit?

    Quote Originally Posted by Everall
    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.

  9. #9
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: a box around QLineEdit?

    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
    Last edited by Everall; 6th February 2006 at 09:27.

  10. #10
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    Quote Originally Posted by wysota
    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:
    Qt Code:
    1. ...
    2. ui.leSSSN->setText(persRec.value(9).toString());
    3. ui.lePart->setText(persRec.value(10).toString());
    4. ui.leTotalIncome->setText(QString::number(persRec.value(11).toDouble(),'f',2));
    5. ui.leP2Line1->setText(QString::number(persRec.value(12).toDouble(),'f',2));
    6. ui.leP2Line2->setText(QString::number(persRec.value(13).toDouble(),'f',2));
    7. ui.leP2Line3->setText(QString::number(persRec.value(14).toDouble(),'f',2));
    8. ui.leP2Line4->setText(QString::number(persRec.value(15).toDouble(),'f',2));
    9. ui.leP2Line5->setText(QString::number(persRec.value(16).toDouble(),'f',2));
    10. ui.leP2Line6->setText(QString::number(persRec.value(17).toDouble(),'f',2));
    11. ui.leP2Line7a->setText(QString::number(persRec.value(18).toDouble(),'f',2));
    12. ...
    To copy to clipboard, switch view to plain text mode 
    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.

  11. #11
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    99
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: a box around QLineEdit?

    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:
    Qt Code:
    1. QList<QWidget *> widgets = parentWidget.findChildren<QWidget *>("widgetname");
    2. This example returns all QPushButtons that are children of parentWidget:
    3. QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>();
    To copy to clipboard, switch view to plain text mode 
    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

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: a box around QLineEdit?

    Keep an array of pointers to QLineEdits and then:

    Qt Code:
    1. for(int i=0;i<10;i++){
    2. lineedits[i]>setText(QString::number(persRec.value(i+11).toDouble(),'f',2));
    3. }
    To copy to clipboard, switch view to plain text mode 

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

  13. #13
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    Quote Originally Posted by Everall
    ...
    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...

  14. #14
    Join Date
    Jan 2006
    Location
    Lincoln, NE USA
    Posts
    177
    Thanks
    3
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: a box around QLineEdit?

    Quote Originally Posted by wysota
    ...
    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.

Similar Threads

  1. Replies: 10
    Last Post: 12th February 2009, 08:23
  2. problem with QLineEdit and QPalette
    By impeteperry in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2008, 18:05
  3. QLineEdit
    By rick_st3 in forum Newbie
    Replies: 1
    Last Post: 14th June 2008, 10:05
  4. Pointer Question related to QLineEdit
    By ChrisReath in forum Qt Programming
    Replies: 1
    Last Post: 23rd May 2008, 16:13
  5. QValidator, regular expressions and QLineEdit
    By hvengel in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 02:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.