Results 1 to 8 of 8

Thread: How to change the color of lineedit border

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 2 Times in 2 Posts

    Default Re: How to change the color of lineedit border

    Hii all


    I tried the following code by using inheritance concept ,project is getting compiled without any errors and warnings but I'm not getting any executed file I even tried some other code,at least to change the color of the frame by using stylesheet nothing is working here....How to get a frame less line edit in a frame less black colored window ?? anyone please help me ....

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include <QLineEdit>
    4.  
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. QLineEdit *LineEdit = new QLineEdit;
    11.  
    12. LineEdit->setFrame("False");
    13.  
    14.  
    15. //LineEdit->setAttribute(Qt.WA_MacShowFocusRect, 0);
    16. QMainWindow window;
    17. window.setWindowFlags(Qt::WindowTitleHint | Qt::FramelessWindowHint);
    18. window.setWindowTitle(" ");
    19. window.setFixedSize(272,480);
    20.  
    21. MainWindow w;
    22. w.show();
    23. return a.exec();
    24. }
    25. [CODE]
    To copy to clipboard, switch view to plain text mode 
    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    namespace Ui {
    class MainWindow;
    }

    class MainWindow : public QMainWindow {
    Q_OBJECT
    public:
    MainWindow(QWidget *parent = 0);

    ~MainWindow();

    protected:
    void changeEvent(QEvent *e);


    private:
    Ui::MainWindow *ui;
    };

    class LineEdit : public QMainWindow {
    Q_OBJECT
    public:
    void setFrame ( bool );

    };

    #endif // MAINWINDOW_H
    //QLineEdit::setFrame(false);
    //void QLineEdit::setFrame ( bool ) [virtual slot]
    [/CODE]

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QLineEdit>
    4.  
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent, Qt::FramelessWindowHint),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. this->setStyleSheet("background-color:rgb(13, 13, 13);");
    12.  
    13. //this->ui->LineEdit->setStyleSheet("border-color:rgb(13, 13, 13);");
    14. // this->setStyleSheet("QLineEdit{foregroundRole-color : rgb(244, 244, 244); }");
    15.  
    16. //this->setStyleSheet("QLineEdit{border: black;}");
    17.  
    18. }
    19. MainWindow::~MainWindow()
    20. {
    21. delete ui;
    22. }
    23. void MainWindow::changeEvent(QEvent *e)
    24. {
    25. QMainWindow::changeEvent(e);
    26. switch (e->type()) {
    27. case QEvent::LanguageChange:
    28. ui->retranslateUi(this);
    29. break;
    30. default:
    31. break;
    32. }
    33. }
    34.  
    35. void QLineEdit::setFrame ( bool )
    36. {
    37. QLineEdit::setFrame(false);
    38. }
    39.  
    40. /*void QLineEdit::setFrame (bool )
    41. {
    42.   QLineEdit::setFrame(false);
    43. }*/
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    15
    Thanked 16 Times in 15 Posts

    Default Re: How to change the color of lineedit border

    did you check the attributes of lineEdit manually? look for its properties in your form inside your project.

  3. #3
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 2 Times in 2 Posts

    Default Re: How to change the color of lineedit border

    @ saman_artorious

    I got it thank you
    Last edited by Harini; 25th November 2013 at 12:17.

  4. #4
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11
    Thanks
    15
    Thanked 16 Times in 15 Posts

    Default Re: How to change the color of lineedit border

    Quote Originally Posted by Harini View Post
    sorry can u please explain me in detail...
    inside your form, where you design your UI, on the right side. click on the lineEdit and check its properties on the right side, should you find what you are after there.

  5. The following user says thank you to saman_artorious for this useful post:

    Harini (25th November 2013)

  6. #5
    Join Date
    Nov 2013
    Location
    Hyderabad
    Posts
    52
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    13
    Thanked 2 Times in 2 Posts

    Question Re: How to change the color of lineedit border

    Hi its me again

    Actually we're working for PDA (Personal Digital Assistance)product.when I try to compile this code by keeping it in our product and trying to interface with other code,getting an error-asking some libraries.How can I include that libraries is my code correct? can anyone please help me???
    Qt Code:
    1. include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3. #include <QLineEdit>
    4.  
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. QLineEdit *LineEdit = new QLineEdit;
    11. LineEdit->setStyleSheet("border: black");
    12.  
    13. QMainWindow window;
    14. window.setWindowFlags(Qt::WindowTitleHint | Qt::FramelessWindowHint);
    15. window.setWindowTitle(" ");
    16. window.setFixedSize(272,480);
    17.  
    18. MainWindow w;
    19. w.show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3. #include <QLineEdit>
    4.  
    5.  
    6. MainWindow::MainWindow(QWidget *parent) :
    7. QMainWindow(parent, Qt::FramelessWindowHint),
    8. ui(new Ui::MainWindow)
    9. {
    10. ui->setupUi(this);
    11. this->setStyleSheet("background-color:rgb(13, 13, 13);");
    12.  
    13.  
    14. }
    15. MainWindow::~MainWindow()
    16. {
    17. delete ui;
    18. }
    19. void MainWindow::changeEvent(QEvent *e)
    20. {
    21. QMainWindow::changeEvent(e);
    22. switch (e->type()) {
    23. case QEvent::LanguageChange:
    24. ui->retranslateUi(this);
    25. break;
    26. default:
    27. break;
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5.  
    6. namespace Ui {
    7. class MainWindow;
    8. }
    9.  
    10. class MainWindow : public QMainWindow {
    11. Q_OBJECT
    12. public:
    13. MainWindow(QWidget *parent = 0);
    14.  
    15. ~MainWindow();
    16.  
    17. protected:
    18. void changeEvent(QEvent *e);
    19.  
    20.  
    21. private:
    22. Ui::MainWindow *ui;
    23. };
    24.  
    25. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    Last edited by Harini; 5th December 2013 at 06:49.

Similar Threads

  1. random color and lineedit
    By smemamian in forum Newbie
    Replies: 5
    Last Post: 8th April 2013, 10:41
  2. Replies: 4
    Last Post: 8th September 2011, 08:22
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. How to set the BORDER COLOR of QDialog?
    By ashukla in forum Qt Programming
    Replies: 6
    Last Post: 13th November 2007, 16:09
  5. Get Color from LineEdit
    By raphaelf in forum Newbie
    Replies: 4
    Last Post: 15th May 2007, 15:30

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
  •  
Qt is a trademark of The Qt Company.