Qt: How to Access Inherited Widget?

Qt: How to Access Inherited Widget?

Content Index :

Qt: How to Access Inherited Widget?
Tag : cpp , By : dantino
Date : January 12 2021, 09:11 PM

may help you . Your question could do with a example to make it more clear.
But, if what you are doing is something like
class MyWidget : public QPushButton {
class Base {
    int base_int;

class Derived : public Base {
    int derived_int;
    int getBaseInt() const { return base_int; }
    int getDerivedInt() const { return derived_int; }
int getBaseInt() const { return Base::base_int; }

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Dojo1.9: Custom widget inherited from another custom widget template string update not reflected

Tag : development , By : Ray
Date : March 29 2020, 07:55 AM
To fix this issue data-dojo-attach-point (which you should use for 1.6+ instead of dojoAttachPoint) allows you to have handles for dom nodes in your template.. It is parsed by _TemplatedMixin's buildRendering(), so it will be available in your buildRendering method just after this.inherited line.
You can not set data-dojo-attach-point using setAttribute, it can only be defined in templates to be parsed by TemplatedMixin. If you need your child widget to add some markup in addition to what there is in its parent's template, you can define a variable in your parent's markup, and overwrite it in your child widget:
<div data-dojo-attach-point="widget">
    <div data-dojo-attach-point="title">${name}</div>
    <div data-dojo-attach-point="dnmschart"></div>
], function (declare, AbstractWidget) {
return declare("my.widget.view.AbstractChart", [AbstractWidget], {

    buildRendering: function(){
        this.childMarkup = '<div data-dojo-attach-point="gridPlaceHolder"></div>';

How to access inherited of inherited Canvas of TImage?

Tag : delphi , By : jrf
Date : March 29 2020, 07:55 AM
wish of those help You can use a technique similar to what you already have, but access the Canvas property instead of the FCanvas field. The Canvas property is protected, which means it's technically part of the control's interface, so you shouldn't worry about it changing in a future version. (It might still change, but it's not something you should worry about.)
  THackGraphicControl = class(TGraphicControl) end;

LCanvas := THackGraphicControl(Self).Canvas;

How to set border to widget, inherited from QFrame?

Tag : cpp , By : Gerhard Miller
Date : March 29 2020, 07:55 AM
this one helps. You have to draw on top of the QFrame, the rectangle inside the edge you get through contentsRect(). The setFrameStyle(), setLineWidth(), and setLineWidth() methods do it in the constructor since you will call it only once.

#include <QFrame>

class LedIndicator : public QFrame
    Q_PROPERTY(bool state READ state WRITE setState)
    Q_PROPERTY(QColor onColor READ onColor WRITE setOnColor)
    Q_PROPERTY(QColor offColor READ offColor WRITE setOffColor)
    Q_PROPERTY(Qt::BrushStyle onPattern READ onPattern WRITE setOnPattern)
    Q_PROPERTY(Qt::BrushStyle offPattern READ offPattern WRITE setOffPattern)
    Q_PROPERTY(int side READ side WRITE setSide)
    LedIndicator(QWidget *parent = nullptr);
    bool state() const;
    void setState(bool state);

    QColor onColor() const;
    void setOnColor(const QColor &onColor);

    QColor offColor() const;
    void setOffColor(const QColor &offColor);

    Qt::BrushStyle onPattern() const;
    void setOnPattern(const Qt::BrushStyle &onPattern);

    Qt::BrushStyle offPattern() const;
    void setOffPattern(const Qt::BrushStyle &offPattern);
    int side() const;
    void setSide(int side);
public slots:
    void toggle();
    void paintEvent(QPaintEvent *event);
    bool m_state;
    QColor m_onColor;
    QColor m_offColor;
    Qt::BrushStyle m_onPattern;
    Qt::BrushStyle m_offPattern;
    int m_side;

#include "ledindicator.h"

#include <QPainter>

LedIndicator::LedIndicator(QWidget *parent) :
    setFrameStyle( QFrame::Box | QFrame::Raised);

void LedIndicator::paintEvent(QPaintEvent *event) {
    QPainter p(this);
    QBrush b = m_state ? QBrush(m_onColor, m_onPattern): QBrush(m_offColor, m_offPattern);
    p.fillRect(contentsRect(), b);

int LedIndicator::side() const
    return m_side;

void LedIndicator::setSide(int side)
    m_side = side;
    setFixedSize(side, side);

Qt::BrushStyle LedIndicator::offPattern() const
    return m_offPattern;

void LedIndicator::setOffPattern(const Qt::BrushStyle &offPattern)
    m_offPattern = offPattern;

void LedIndicator::toggle()

Qt::BrushStyle LedIndicator::onPattern() const
    return m_onPattern;

void LedIndicator::setOnPattern(const Qt::BrushStyle &onPattern)
    m_onPattern = onPattern;

QColor LedIndicator::offColor() const
    return m_offColor;

void LedIndicator::setOffColor(const QColor &offColor)
    m_offColor = offColor;

QColor LedIndicator::onColor() const
    return m_onColor;

void LedIndicator::setOnColor(const QColor &onColor)
    m_onColor = onColor;

bool LedIndicator::state() const
    return m_state;

void LedIndicator::setState(bool state)
    m_state = state;

BlocProvider not available within inherited widget

Tag : flutter , By : davidg
Date : March 29 2020, 07:55 AM
seems to work fine You should use your BlocProvider() above the MaterialApp widget.
Navigator is a widget added by MaterialApp and when you call it to change a route it replaces the widget in home: property and hence replaces your BlocProvider.
 Widget build(BuildContext context) {
  return BlocProvider(
    child: MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'E-Form',
      color: Color(0xFF44697D),
      home: LaunchScreen(),

How to dispose bloc when using Inherited Widget?

Tag : dart , By : Myatus
Date : March 29 2020, 07:55 AM
wish help you to fix your issue That is not possible using Inheritedwidget. The widget is not made to handle data, but to share it.
You have to wrap your Inheritedwidget into a StatefulWidget and use the dispose of the latter
Related Posts Related QUESTIONS :
  • Is it possible to roll a significantly faster version of modf
  • Updating pointer using signals and slots
  • How are classes more secure than structures?
  • finding "distance" between two pixel's colors
  • C++ Greatest Number Verification
  • Why does my token return NULL and how can I fix it?(c++)
  • C++ enforce conditions on inherited classes
  • what happened if an exception is not captured?
  • Redundant naming in C/C++ typedefs/structs
  • question about STL thread-safe and STL debugging
  • killing a separate thread having a socket
  • Returning the size of available virtual memory at run-time in C++
  • Parallel computing for integrals
  • How do I force my std::map to deallocate memory used?
  • C++ Templates: implicit conversion, no matching function for call to ctor
  • Adding python script to c++ project
  • C++ private pointer "leaking"?
  • Initializing Primitive Array to One Value
  • how is push_back implemented in STL vector?
  • C++ Profiling: KiFastSystemCallRet
  • Multiple rows with a single INSERT in SQLServer 2008
  • Use super class's address/pointer in initialization list
  • double fork using vfork
  • Convert char pointer (char*) to struct
  • Does anyone have good tips for using pc-lint?
  • C++ How fast is passing around objects?
  • template type's ctor arguments at instantiation time
  • Get list of windows in taskbar on Windows 7?
  • Curl connection options
  • Best cross-platform solution for network server?
  • simple c++ file opening issue
  • Switching from C++ (with a lot of STL use) to C for interpreter building
  • How can I access the JPEG image pixels as a 3D array like we do in MATLAB?
  • What wording in the C++ standard allows static_cast<non-void-type*>(malloc(N)); to work?
  • Avoid allocating in constructor or preserve simplicity (and RAII?)
  • Can C++ raise an error when std array initialization is too small?
  • Reference to end is ambiguous
  • Problem with basic usage of std::enable_if
  • How to print out a decimal number as octal number using setiosflags in C++
  • Open Visual Studio with solution and specific file and line
  • Enum value based on template type
  • Is there any way to swap nodes in std::list?
  • How to copy QString into wchar_t buffer
  • Make the compiler generate an empty default function for an std::function
  • Insert or push_back to end of a std::vector?
  • Best practice for const temporary types
  • Include CSV File in Complied Binary
  • Issue with binding non static function to callback
  • How can read from some files and write content of them with different form into files with same names
  • Why does auto deduce this variable as double and not float?
  • no instance of overloaded function "std::make_unique" matches the argument list, but works with unique_ptr con
  • How to see array size from a pointer in c++
  • Error taking address of temporary in Eclipse
  • Using an iterator to go through a vector and modify the contents
  • Are extern extern "C", and extern "C" extern, allowed?
  • Can't solve C2660 and C2065 Errors
  • C referencing C++ extern
  • How to write the definition of a derived class in c++?
  • Why when I include <cmath> I need to use the namespace std too?
  • How to assign a 32-bit unsigned integer to a bit field containing 32 bits
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com