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. Custom widget border-radius stylesheet
Forum Updated to NodeBB v4.3 + New Features

Custom widget border-radius stylesheet

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 7.3k 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.
  • E Offline
    E Offline
    elephanten
    wrote on last edited by
    #1

    Well, suppose I have a custom widget with my custom paint event
    @
    class customWidget : public QWidget
    {
    // constructor etc.
    void paintEvent(QPaintEvent *e) { // some painting here };
    }
    @

    Then I add this widget to the layout and set it's stylesheet. Like that
    @
    // in main window constructor
    customWidget *custom=new customWidget;
    custom->setStyleSheet("border-top-right-raduis: 8px;");
    setCentralWidget(custom);
    @

    So, how to account for border-top-right-radius in paint event of my widget? Or how to know of those 8px raduis inside paint event.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      messi
      wrote on last edited by
      #2

      Hi elephanten

      I'm not quiet sure what you are trying to do?
      It seams to me that you are mixing the stylesheet approach with the inherit by QStyle approach.

      Why would you need stylesheet in your customwidget where you have full control of paintEvent?

      Also good is to checkout the source of QWidget

      or here

      http://qt-project.org/faq/answer/example_of_how_to_style_qtoolbox_with_qstyle

      or here

      http://qt-project.org/doc/qt-4.8/qstyle.html

      or the examples of qt

      1 Reply Last reply
      0
      • E Offline
        E Offline
        elephanten
        wrote on last edited by
        #3

        Ah, ok.
        My custom widget is placed inside qscrollarea, which in turn has a stylesheet, specifying border-raduis. My widget is then rendered over the border-radius, which is ugly. Is it true, that I, oh-ah, just have do like that:
        @
        class customWidget : public QAbstractSrollArea
        {
        // all the mess with painting
        };
        @

        Hmm?

        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