本文整理汇总了C++中QWidget::className方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::className方法的具体用法?C++ QWidget::className怎么用?C++ QWidget::className使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::className方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setData
void eDBField::setData( QWidget *o, aCfg *md )
{
// const QObject *o = sender();
if ( o ) {
if ( o->className() != QString("wDBField") || !md ) {
reject();
return;
}
}
else {
reject();
return;
}
int w=0, d=0, idx=0;
unsigned int i;
long oid, widgetId, fieldId;
QString pn;
aWidget *widget;
wDBField *field = (wDBField*)o;
QWidget *pWidget = field->parentWidget();
while ( pWidget ) {
pn = "";
pn = pWidget->className();
if ( pn == QString("wCatalogue") || pn == QString("wDocument") ) break;
pWidget = pWidget->parentWidget();
}
if ( pn == QString("wCatalogue") ) widget = (wCatalogue*)pWidget; else
if ( pn == QString("wDocument") ) widget = (wDocument*)pWidget; else
return;
widgetId = widget->getId();
//fieldId = field->getId();
if ( widgetId ) widget->setMDObject( md->find( widgetId ) );
// printf( "parent widget id = %i\n", widgetId );
// printf( "field id = %i\n", fieldId );
// printf( "metadata id = %i\n", md->id( *widget->getMDObject() ) );
QStringList tlist = md->types( md_field, widget->getMDObject() );
otypes.clear();
eType->clear();
for ( QStringList::Iterator it = tlist.begin(); it != tlist.end(); ++it ) {
otypes.append( (*it).section( "\t", 0, 0 ) );
eName->insertItem( (*it).section("\t", 1, 1 ), idx++ );
}
for ( i = 0 ; i < otypes.count(); i++ ) {
oid = 0;
if( otypes[i][0] == 'O' ) {
sscanf( (const char *)otypes[ i ], "O %d", &oid );
if ( oid == fieldId ) {
eName->setCurrentItem( i );
break;
}
}
}
}
示例2: QWidget
/*!
* \en Creates catalog editor widget. \_en
* \ru Создает виджет для редактирования каталога.
* В принципе он не предусмотрен использоваться ни как иначе, кроме как часть
* объекта wField, т.е его родительский объект должен быть wField
* или его наследник для обеспечения корректной инициализации.
* При создании объекта runtime не предусмотрено, за исключением случая,
* когда виджет используется в составе wField в объекте wDBTable.
* \param parent - \en parent object. \_en \ru родительский объект. \_ru
* \param name - \en name \_en \ru имя \_ru
* \param catname \en not used \_en \ru не используется \_ru
*/
wCatalogEditor::wCatalogEditor( wField *parent,
const char *name,
const char *catname) : QWidget(parent, name)
{
QWidget* w =0;
md = NULL;
QString str;
label = new QLabel(parent, name);
label->setFrameShape(QFrame::Box);
w =(QWidget*) parent->parent()->parent();
str = parent->getFieldType();
catId = atoi(str.remove(0,2));// gets catalog id.
if(w)
{
if(strcmp(w->className(),"wDBTable")==0) // wField is element wDBTable
{
initCat(((wDBTable*)w)->db);
}
}
}
示例3: doLayout
void VerticalLayout::doLayout()
{
bool needMove, needReparent;
if ( !prepareLayout( needMove, needReparent ) )
return;
QVBoxLayout *layout = (QVBoxLayout*)WidgetFactory::createLayout( layoutBase, 0, WidgetFactory::VBox );
for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
if ( needReparent && w->parent() != layoutBase )
w->reparent( layoutBase, 0, QPoint( 0, 0 ), FALSE );
if ( qstrcmp( w->className(), "Spacer" ) == 0 )
layout->addWidget( w, 0, ( (Spacer*)w )->alignment() );
else
layout->addWidget( w );
w->show();
}
finishLayout( needMove, layout );
}
示例4: setSize
void JabberSearch::setSize()
{
if (!m_bDirty || (parent() == NULL))
return;
m_bDirty = false;
for (QWidget *p = this; p; p = p->parentWidget()){
QSize s = p->sizeHint();
QSize s1 = QSize(p->width(), p->height());
p->setMinimumSize(s);
p->resize(QMAX(s.width(), s1.width()), QMAX(s.height(), s1.height()));
log(L_DEBUG, "%s: %u %u %u %u", p->className(), s.width(), s.height(), s1.width(), s1.height());
if (p->layout())
p->layout()->invalidate();
if (p == topLevelWidget())
break;
}
QWidget *t = topLevelWidget();
QSize s = t->sizeHint();
t->resize(QMAX(t->width(), s.width()), QMAX(t->height(), s.height()));
t->adjustSize();
}
示例5: if
bool
Container::eventFilter(QObject *s, QEvent *e)
{
// kdDebug() << e->type() << endl;
switch(e->type())
{
case QEvent::MouseButtonPress:
{
m_insertBegin = QPoint(-1, -1);
m_mousePressEventReceived = true;
kdDebug() << "QEvent::MouseButtonPress sender object = " << s->name()
<< "of type " << s->className() << endl;
kdDebug() << "QEvent::MouseButtonPress this = " << name() << endl;
m_moving = static_cast<QWidget*>(s);
QMouseEvent *mev = static_cast<QMouseEvent*>(e);
m_grab = QPoint(mev->x(), mev->y());
// we are drawing a connection
if(FormManager::self()->isCreatingConnection()) {
drawConnection(mev);
return true;
}
if(((mev->state() == ControlButton) || (mev->state() == ShiftButton))
&& (!FormManager::self()->isInserting())) // multiple selection mode
{
if(m_form->selectedWidgets()->findRef(m_moving) != -1) // widget is already selected
{
if(m_form->selectedWidgets()->count() > 1) // we remove it from selection
unSelectWidget(m_moving);
else // the widget is the only selected, so it means we want to copy it
{
//m_copyRect = m_moving->geometry();
m_state = CopyingWidget;
if(m_form->formWidget())
m_form->formWidget()->initBuffer();
}
}
else // the widget is not yet selected, we add it
setSelectedWidget(m_moving, true, (mev->button() == RightButton));
}
else if((m_form->selectedWidgets()->count() > 1))//&& (!m_form->manager()->isInserting())) // more than one widget selected
{
if(m_form->selectedWidgets()->findRef(m_moving) == -1) // widget is not selected, it becomes the only selected widget
setSelectedWidget(m_moving, false, (mev->button() == RightButton));
// If the widget is already selected, we do nothing (to ease widget moving, etc.)
}
else// if(!m_form->manager()->isInserting())
setSelectedWidget(m_moving, false, (mev->button() == RightButton));
// we are inserting a widget or drawing a selection rect in the form
if((/*s == m_container &&*/ FormManager::self()->isInserting()) || ((s == m_container) && !m_toplevel))
{
int tmpx,tmpy;
if(!FormManager::self()->snapWidgetsToGrid() || (mev->state() == (LeftButton|ControlButton|AltButton)))
{
tmpx = mev->x();
tmpy = mev->y();
}
else
{
int gridX = m_form->gridSize();
int gridY = m_form->gridSize();
tmpx = int( (float)mev->x() / ((float)gridX) + 0.5 ); // snap to grid
tmpx *= gridX;
tmpy = int( (float)mev->y() / ((float)gridY) + 0.5 );
tmpy *= gridX;
}
m_insertBegin = (static_cast<QWidget*>(s))->mapTo(m_container, QPoint(tmpx, tmpy));
if(m_form->formWidget())
m_form->formWidget()->initBuffer();
if(!FormManager::self()->isInserting())
m_state = DrawingSelectionRect;
}
else {
if(s->inherits("QTabWidget")) // to allow changing page by clicking tab
return false;
}
if (m_objectForMouseReleaseEvent) {
const bool res = handleMouseReleaseEvent(m_objectForMouseReleaseEvent, &m_mouseReleaseEvent);
m_objectForMouseReleaseEvent = 0;
return res;
}
return true;
}
case QEvent::MouseButtonRelease:
{
QMouseEvent *mev = static_cast<QMouseEvent*>(e);
if (!m_mousePressEventReceived) {
m_mouseReleaseEvent = *mev;
m_objectForMouseReleaseEvent = s;
return true;
}
m_mousePressEventReceived = false;
//.........这里部分代码省略.........
示例6: switch
QWidget *KFileMetaInfoWidget::makeWidget()
{
QString valClass;
QWidget *w;
switch(m_value.type())
{
case QVariant::Invalid: // no type
// just make a label
w = new QLabel(i18n("<Error>"), this, "label");
break;
case QVariant::Int: // an int
case QVariant::UInt: // an unsigned int
w = makeIntWidget();
break;
case QVariant::Bool: // a bool
w = makeBoolWidget();
break;
case QVariant::Double: // a double
w = makeDoubleWidget();
break;
case QVariant::Date: // a QDate
w = makeDateWidget();
break;
case QVariant::Time: // a QTime
w = makeTimeWidget();
break;
case QVariant::DateTime: // a QDateTime
w = makeDateTimeWidget();
break;
#if 0
case QVariant::Size: // a QSize
case QVariant::String: // a QString
case QVariant::List: // a QValueList
case QVariant::Map: // a QMap
case QVariant::StringList: // a QStringList
case QVariant::Font: // a QFont
case QVariant::Pixmap: // a QPixmap
case QVariant::Brush: // a QBrush
case QVariant::Rect: // a QRect
case QVariant::Color: // a QColor
case QVariant::Palette: // a QPalette
case QVariant::ColorGroup: // a QColorGroup
case QVariant::IconSet: // a QIconSet
case QVariant::Point: // a QPoint
case QVariant::Image: // a QImage
case QVariant::CString: // a QCString
case QVariant::PointArray: // a QPointArray
case QVariant::Region: // a QRegion
case QVariant::Bitmap: // a QBitmap
case QVariant::Cursor: // a QCursor
case QVariant::ByteArray: // a QByteArray
case QVariant::BitArray: // a QBitArray
case QVariant::SizePolicy: // a QSizePolicy
case QVariant::KeySequence: // a QKeySequence
#endif
default:
w = makeStringWidget();
}
kdDebug(7033) << "*** item " << m_item.key() << "is a " << m_item.value().typeName() << endl;
if(m_validator)
kdDebug(7033) << " and validator is a " << m_validator->className() << endl;
kdDebug(7033) << "*** created a " << w->className() << " for it\n";
return w;
}
示例7: keyPressed
bool IMPluginSwitcher::keyPressed(QKeyEvent *p_keyPressEvent, ZInputField* field)
//bool IMPluginSwitcher::keyReleased(QKeyEvent *p_keyPressEvent, ZInputField* field)
//bool IMPluginSwitcher::hack(QKeyEvent *p_keyPressEvent, ZInputField* field)
{
toLog( "##### Start my keyPressed! ");
bool ret = keyPressedInternal( p_keyPressEvent, field );
if ( field != NULL && p_keyPressEvent->key() == KEY_GREEN )
{
toLog( "##### Key code is GREEN !!! " );
toLog( "##### Getting editor" );
QWidget * editor = field->getEditorWidget();
toLog( "##### Create action dlg" );
EDIT_FILD_TYPE tupeEditor = TYPE_UDEFINE;
{ //For not use more memory, to store class name
QString s = QString(editor->className());
toLog( "##### Editor class: "+s );
if ( s.find("MultiLineEdit") != -1)
tupeEditor = TYPE_MULTI_LINE_EDIT;
else if ( s.find("LineEdit") != -1 )
tupeEditor = TYPE_LINE_EDIT;
else if ( (s.find("ZTextEdit") != -1) || (s.find("MMS_PageWidget") != -1) )
tupeEditor = TYPE_TEXT_EDIT;
else if ( s.find("SVGCanvas") != -1 )
return false; //Copy past don't work(
}
int selected=CANCEL_CODE;
if ( onSelectText )
{
toLog( "##### Auto select" );
selected = ACTION_SELECT_END;
} else
{
QRect rect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
ZOptionsMenu * menu = new ZOptionsMenu (rect, editor);//editor->topLevelWidget()
toLog( "##### Insert item to list" );
INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_COPY", "Copy"), ACTION_COPY);
INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_INSERT", "Paste"), ACTION_PAST);
int x1=0,x2=0,y1,y2;
bool oldSel=false;
if ( tupeEditor != TYPE_UDEFINE )
{
INSERT_ITEM(ZWidget::tr("TXT_RID_MENU_CUT", "Cut"), ACTION_CUT);
INSERT_SEP();
INSERT_ITEM(ZWidget::tr("TXT_RID_OPTION_SELECT_ALL", "onSelectText all"), ACTION_SELECT_ALL);
INSERT_ITEM(ZWidget::tr("TXT_RID_HEADER_SELECT", "Select"), ACTION_SELECT_START);
//save curren state of input fild and get cursor point
QPoint pos(0,0);
switch ( tupeEditor )
{
case TYPE_MULTI_LINE_EDIT:
pos = ((ZMultiLineEdit*)editor)->mapToGlobal(((ZMultiLineEdit*)editor)->cursorPoint());
oldSel = ((ZMultiLineEdit*)editor)->hasMarkedText();
if ( oldSel )
((ZMultiLineEdit*)editor)->getMarkedRegion( &x1, &y1, &x2, &y2 );
else
((ZMultiLineEdit*)editor)->getCursorPosition( &x1, &y1 );
break;
case TYPE_LINE_EDIT:
pos = ((ZLineEdit*)editor)->mapToGlobal(((ZLineEdit*)editor)->cursorPoint());
oldSel = ((ZLineEdit*)editor)->hasMarkedText();
if ( !oldSel )
x1=((ZLineEdit*)editor)->cursorPosition();
break;
case TYPE_TEXT_EDIT:
default:
pos = editor->mapToGlobal( field->getCursorPos() );
break;
}
menu->setPosition(ZOptionsMenu::TopLeft, pos );
}
toLog( "##### Show dlg" );
menu->popup();
while ( !menu->isHidden() ) qApp->processEvents();
selected = menu->getCurrentSelectedItemId();
//load state of input fild
if ( tupeEditor>0 )
{
switch ( tupeEditor )
{
case TYPE_MULTI_LINE_EDIT:
if ( oldSel )
((ZMultiLineEdit*)editor)->setSelection( x1, y1, x2, y2 );
//.........这里部分代码省略.........