Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]QLineEdit Rounded Corners?

[Solved]QLineEdit Rounded Corners?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 11.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    weblife
    wrote on last edited by
    #1

    Is there a way to round the corners of a QLineEdit widget? If not is there a similar widget I could do this to?
    !http://www.themindspot.com/junk/images/shape.jpg(Demonstration)!

    Update Answer:
    @ QLineEdit *lineEdit = new QLineEdit;

      lineEdit -> setStyleSheet("QLineEdit {  border: 2px solid gray;"
                                             "border-radius: 5px;}");@
    

    Brandon Clark

    Brandon Clark
    www.themindspot.com

    1 Reply Last reply
    0
    • J Offline
      J Offline
      jalomic
      wrote on last edited by
      #2

      You can use Style Sheets.
      call setStyleSheet , or set it in designer.
      for example this style:
      "background-color: red; border-radius: 10px; padding: 10px;"

      here more examples:
      http://doc.trolltech.com/4.3/stylesheet-examples.html
      Here docs:
      http://qt-project.org/doc/qt-4.8/stylesheet-syntax.html

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tucnak
        wrote on last edited by
        #3

        Learn about QSS (Qt Style Sheets) - it allows to add CSS styling to your Qt application.

        file.cpp
        @
        QWidget * widget = new QWidget(this);
        QFile css(":/qss/main.qss");
        if(css.open(QIODevice::ReadOnly)) {
        widget->setStyleSheet(css.readAll());
        }
        @

        main.qss
        @
        QLineEdit {
        border-radius: 30px;
        }
        @

        In QSS file can be allocated any CSS2 rules and most of CSS3 rules.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          weblife
          wrote on last edited by
          #4

          [quote author="tucnak" date="1342510765"]Learn about QSS (Qt Style Sheets) - it allows to add CSS styling to your Qt application.
          [/quote]

          Thats pretty cool. I will, still familiarizing myself with Qt. Liking it so far.

          Brandon Clark
          www.themindspot.com

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved