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 primitive elements in QStyle
QtWS25 Last Chance

Custom primitive elements in QStyle

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

    Hello folks!

    I'm willing to create custom widgets, and thought that using QProxyStyle would be the best way. All I want is to draw custom primitive / control elements. What's the best way for that?

    I'm inheriting from QProxyStyle and overriding drawPrimitve, this way:
    @#pragma once

    #include "CommonGlobal.hpp"
    #include <QProxyStyle>

    class COMMONSHARED_EXPORT Style : public QProxyStyle
    {
    public:
    enum PrimitiveElement
    {
    PE_TimeMarker = QStyle::PE_CustomBase + 1,
    PE_Keyframe
    };

    Style();
    
    void drawPrimitive(QStyle::PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const;
    

    };
    @

    The implementation is just a switch that handles my custom types, and calls baseStyle() to draw the know Qt types.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Phil Weinstein
      wrote on last edited by
      #2

      I think I don't know what you mean by "custom widget". Do you maybe want to just subclass QWidget and provide a paintEvent() handler and user interaction handlers: mouse events and such. (What's "custom" about the custom widgets you want to create?)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Skyrpex
        wrote on last edited by
        #3

        Yes, I mean that. I'm implementing a dopesheet like the one in Blender.

        Actually, I'm using the graphics framework, but I want to be able to further customize my look and feel with different styles, so I thought that delegating the rendering to a QStyle was be the best wayto achieve that.

        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