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. Layout Inheritance
Qt 6.11 is out! See what's new in the release blog

Layout Inheritance

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 420 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    I want to define the basic ui form and inherit it and use it in all future widgets. Can you see if I did it right?

    class QWidgetBase : public QWidget
    {
    	Q_OBJECT
    
    private:
    	Ui::QWidgetBase		ui;
    	QCustomTitleBar*	m_TitleBar;
    	QWidget*			m_pParent;
    	QPushButton*		m_baseBtn;
    
    public:
    	QWidgetBase(QWidget *parent = Q_NULLPTR);
    	~QWidgetBase();
    
    	void	BaseInitialize();
    	void	SetContentsWidget(QWidget* widget);
    };
    
    QWidgetBase::QWidgetBase(QWidget *parent)
    {
    	ui.setupUi(this);
    	
    	m_pParent = parent;
    	BaseInitialize();
    }
    
    QWidgetBase::~QWidgetBase()
    {
    }
    
    void QWidgetBase::BaseInitialize()
    {
    	m_TitleBar = new QCustomTitleBar(this);
    	m_TitleBar->SetVisibleButton(false, false);
    	m_TitleBar->SetVisibleButton(true, false);
    
    	this->ui.base_VL_titlebar->addWidget(m_TitleBar);	
    }
    
    void QWidgetBase::SetContentsWidget(QWidget* widget)
    {
    	QMainViewer* p = qobject_cast<QMainViewer*>(m_pParent);
    	this->ui.widget = p;
    }
    
    
    /**************************************************************************************/
    class QMainViewer : public QWidgetBase
    {
    	Q_OBJECT
    private:
    	Ui::QMainViewer		ui;
    	QWidget*			m_pParent;
    	QCustomTitleBar*	m_pTitlebar;
    
    public:
    	QMainViewer(QWidget* parent = Q_NULLPTR);
    	QMainViewer(QSize size, QWidget* parent = Q_NULLPTR);
    	~QMainViewer();
    
    	void	InitailizeVariable();
    	void	InitailizeCtrl();
    	void	LayoutProperty();
    
    public slots:
    	void	BtnLoginClicked();
    	void	BtnIncubateClicked();
    	void	BtnMethodClicked();
    	void	BtnOpenMethodClicked();
    	void	BtnSettingsClicked();
    };
    

    /*------------------------WidgetBase UI--------------------------/
    7132eb59-e7a4-4e53-8df7-b2b3455431d6-image.png

    /*------------------------MainViewer UI--------------------------/
    c8719f4e-81ef-4d4f-b8a0-ad7532ff2e2b-image.png

    /*------------------------The direction I want to go--------------------------/
    caf45352-a0f7-4cb4-82b8-15ca61a3a975-image.png

    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