Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [Solved]QLineEdit Rounded Corners?

    General and Desktop
    3
    4
    10494
    Loading More Posts
    • 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
      weblife last edited by

      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 Reply Quote 0
      • J
        jalomic last edited by

        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 Reply Quote 0
        • T
          tucnak last edited by

          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 Reply Quote 0
          • W
            weblife last edited by

            [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 Reply Quote 0
            • First post
              Last post