For I use layout to arrange the control's position.But i have to inherit some control,for example, qtable,to realize some function.How Can I reach this? Thanks!!
For I use layout to arrange the control's position.But i have to inherit some control,for example, qtable,to realize some function.How Can I reach this? Thanks!!
Well, I'm not sure this is what you mean, but...
If you have a class that is derived from a widget available in designer like "class myCustomTableView : public QTableView" then you can right click the widget in designer and choose promote to custom widget. You must specify the proper header file for your custom widget.
What I mean is that ,for example,if there is a QTable in *.ui, and I have a class namedOriginally Posted by jrideout
QMyTable derived from QTable,How can i relate these two?In Mfc,I can use CWnd::SubclassDlgItem to do this. this is the detailed description in MSDN.
And I do my best to understand and test what you descripted,but I have no idea at last:
,there is no such option in right click options.Originally Posted by jrideout
CWnd::SubclassDlgItem
This method dynamically subclasses a control created from a dialog box template, and attach it to this CWnd object. When a control is dynamically subclassed, windows messages will route through the CWnd message map and call message handlers in the CWnd class first. Messages that are passed to the base class will be passed to the default message handler in the control.
This method attaches the Windows control to a CWnd object and replaces the WndProc and AfxWndProc functions of the control. The function stores the old WndProc in the location returned by the CWnd::GetSuperWndProcAddr method.
BOOL SubclassDlgItem(
UINT nID,
CWnd* pParent );
Parameters
nID
Specifies the control ID.
pParent
Specifies the control parent, this is usually a dialog box.
Return Value
Nonzero if the function is successful; otherwise, it is zero.
Example
class CMyButton : public CButton {...};
// m_myButton is a CMyButton object member of CAboutDlg
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// IDC_BUTTON1 is the ID for a button on the
// dialog template used for CAboutDlg.
m_myButton.SubclassDlgItem(IDC_BUTTON1, this);
return TRUE; // Return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
Last edited by coralbird; 5th April 2006 at 02:15.
Sorry my solution is for Qt4, I just noticed you are using Qt3.
Anyway for folks that read this thread and are using 4 here is a clarification.
In designer, with your form open, right click the widget in the form.
The context menu from right clicking should look like this:
Qt Code:
Change objectName Change toolTip Change whatsThis ------------------ Promote to Custom Widget ------------------ Cut Copy ...To copy to clipboard, switch view to plain text mode
Select "Promote to Custom Widget". A dialog will appear where you can put in the name of the derived class and a header that defines it.
You can edit the ui manually to achive the same effect. Try something like this:
Qt Code:
<ui version="4.0" > <class>Dialog</class> <widget class="QDialog" name="Dialog" > <property name="windowTitle" > <string>Dialog</string> </property> <widget class="QTableView" name="tableView" > </widget> <widget class="myCustomTable" name="customTableView" > </widget> </widget> <customwidgets> <customwidget> <class>myCustomTable</class> <extends>QTableView</extends> <header>mycustomtable.h</header> <container>0</container> <pixmap></pixmap> </customwidget> </customwidgets> </ui>To copy to clipboard, switch view to plain text mode
For qt3 try tools->custom->Edit Custom Widget in designer
coralbird (5th April 2006)
First special thanks to jrideout!
I have find the entrance,and I will test tomorrow. Thanks again.Originally Posted by jrideout
Sure,Through this function,I have reached my target.It's really a usful function.Originally Posted by jrideout
thanks jrideout again.
Bookmarks