Results 1 to 8 of 8

Thread: How to change the color of lineedit border

Threaded 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 How to change the color of lineedit border

    Hello everyone

    I'm using Qt 4.7. I want a main window of size 272x380 with a line edit widget in it of completely black color(total window and lineedit). But here i'm unable to change the color of line edit border
    Here is my code and screen shot attached....As displayed in the screenshot I need that red shaded border also black. I tried different types of code but i din't get it.Can any one please help me regarding this issue??

    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. QLineEdit *LineEdit = new QLineEdit;
    10. LineEdit->setStyleSheet("border: black");
    11. //LineEdit->setStyleSheet("border: 1px solid black");
    12.  
    13.  
    14. //LineEdit->setStyleSheet("QLineEdit{background: black;}");
    15. // ("QLineEdit { background-color : rgb(45, 45, 45); }");
    16. //LineEdit>setStyleSheet("QLineEdit{background: black;}");
    17.  
    18.  
    19. QMainWindow window;
    20. window.setWindowFlags(Qt::WindowTitleHint | Qt::FramelessWindowHint);
    21. window.setWindowTitle(" ");
    22. window.setFixedSize(272,480);
    23.  
    24. MainWindow w;
    25. w.show();
    26. return a.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

    #include "mainwindow.h"
    #include "ui_mainwindow.h"


    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent, Qt::FramelessWindowHint),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    this->setStyleSheet("background-color:rgb(13, 13, 13);");
    // this->setStyleSheet("QLineEdit{foregroundRole-color : rgb(244, 244, 244); }");

    //this->setStyleSheet("QLineEdit{border: black;}");


    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::changeEvent(QEvent *e)
    {
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
    ui->retranslateUi(this);
    break;
    default:
    break;
    }
    }
    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. ~MainWindow();
    15.  
    16. protected:
    17. void changeEvent(QEvent *e);
    18.  
    19. private:
    20. Ui::MainWindow *ui;[QTCLASS][/QTCLASS]
    21. };
    22.  
    23. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

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.