Example #1
1
/*!
    Resizes the top-level widget containing this widget. The event is
    in \a e.
*/
void QSizeGrip::mouseMoveEvent( QMouseEvent * e )
{
    if ( e->state() != LeftButton )
	return;

    QWidget* tlw = qt_sizegrip_topLevelWidget(this);
    if ( tlw->testWState(WState_ConfigPending) )
	return;

    QPoint np( e->globalPos() );

    QWidget* ws = qt_sizegrip_workspace( this );
    if ( ws ) {
	QPoint tmp( ws->mapFromGlobal( np ) );
	if ( tmp.x() > ws->width() )
	    tmp.setX( ws->width() );
	if ( tmp.y() > ws->height() )
	    tmp.setY( ws->height() );
	np = ws->mapToGlobal( tmp );
    }

    int w;
    int h = np.y() - p.y() + s.height();

    if ( QApplication::reverseLayout() )
	w = s.width() - ( np.x() - p.x() );
    else
	w = np.x() - p.x() + s.width();

    if ( w < 1 )
	w = 1;
    if ( h < 1 )
	h = 1;
    QSize ms( tlw->minimumSizeHint() );
    ms = ms.expandedTo( minimumSize() );
    if ( w < ms.width() )
	w = ms.width();
    if ( h < ms.height() )
	h = ms.height();

    if (QApplication::reverseLayout()) {
	tlw->resize( w, h );
	if (tlw->size() == QSize(w,h))
	    tlw->move( tlw->x() + ( np.x()-p.x() ), tlw->y() );
    } else {
	tlw->resize( w, h );
    }
#ifdef Q_WS_WIN
    MSG msg;
    while( PeekMessage( &msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE ) )
      ;
#endif
    QApplication::syncX();

    if ( QApplication::reverseLayout() && tlw->size() == QSize(w,h) ) {
	s.rwidth() = tlw->size().width();
	p.rx() = np.x();
    }
}
Example #2
0
void MainWindow::setup(){
    cntnumber = 1;
    QWidget *widget = new QWidget(this);
    QHBoxLayout *layout = new QHBoxLayout(widget);
    layout->addStretch(20);
    layout->addWidget(formheadl);
    layout->addStretch(20);
#if DUAL_SYSTEM
    layout->addWidget(formheadr);
    layout->addStretch(20);
    widget->setFixedSize(780,280);
    widget->move(10,80);
#else
    widget->setFixedSize(460,280);
    widget->move(170,80);
#endif

    connect(&hmiData,SIGNAL(time1sOuted()),this,SLOT(Timeout1s()));
    connect(&hmiData,SIGNAL(clothFinishCountChanged(int)),label_FinishCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(clothSetCountChanged(int)),label_setCount,SLOT(setNum(int)));
    connect(&patternData,SIGNAL(patternChanged(QString,QString)), SLOT(onpatternChange(QString,QString)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopleft(int)),label_loopLeft,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopStart(int)),label_loopStart,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopend(int)),label_loopEnd,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_loopTatal(int)),label_loopCount,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(hmi_cntNumber(unsigned short)),SLOT(runPatternRowChange(unsigned short)));
    connect(&hmiData,SIGNAL(hmi_jitouxiangduizhengshu(int)),label_zwz,SLOT(setNum(int)));
    connect(&hmiData,SIGNAL(xtGuilingError()),SLOT(onXtGuilingError()));
    connect(&hmiData,SIGNAL(xtRunOrGuiling(bool)),qMdPushButton_5,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(lineLock(bool)),qMdPushButton_6,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(speedLimit(bool)),qMdPushButton_8,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(stopPerOne(bool)),qMdPushButton_9,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(alarmLimit(bool)),qMdPushButton_10,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(shazuiUp(bool)),qMdPushButton_11,SLOT(setChecked(bool)));
    connect(&hmiData,SIGNAL(runing(bool)),SLOT(onHmidataRuning(bool)));
    connect(&hmiData,SIGNAL(powerDown()),SLOT(onPowerDown()));
    connect(&paramaData,SIGNAL(changed()),SLOT(onParamChanded()));
    azllist<<tr("空")<<tr("翻针")<<tr("编织");
    hzllist<<tr("空")<<tr("吊目")<<tr("接针")<<tr("吊目2")<<tr("编松2");
#if DUAL_SYSTEM
    connect(&hmiData,SIGNAL(sigDankouLock(bool)),SLOT(onDankouLock(bool)));
    label_dankoulock->setText(hmiData.dankouLock()?tr("锁定"):tr("不锁定"));
#else
    frame_dankoulock->hide();
#endif

}
Example #3
0
void wxWindowQt::DoMoveWindow(int x, int y, int width, int height)
{
    QWidget *qtWidget = GetHandle();

    qtWidget->move( x, y );
    qtWidget->resize( width, height );
}
Example #4
0
void TextEdit::keyPressEvent(QKeyEvent *e){

	QTextEdit::keyPressEvent(e);
	if (completationOpen) return; // don't open a second completationbox

	QTextCursor cursor = textCursor();

	QChar rchar = cursor.block().text()[cursor.position() - cursor.block().position()];
	if (!rchar.isLetterOrNumber()){

		//request a new completation list
		QString lstring = cursor.block().text().left(cursor.position() - cursor.block().position());
		parent->requestCompletationList(lstring);
		QString last = lstring.split(QRegExp("\\W")).last();
		//open the completationbox if the list has more than one entry
		if(parent->completationList.count() != 0 && !rchar.isLetterOrNumber() ){;
			QWidget *box = new CompletionBox(this, parent->completationList, last.left(last.length() - parent->completationOffset -1));
			box->move(mapToGlobal(cursorRect().bottomLeft()));
			box->show();
			connect(parent,SIGNAL(HelpStringSignal(const QString&)),box,SLOT(setHelpString(const QString&)));
			connect(box,SIGNAL(requestHelpString(const QString&)), parent, SLOT(emitRequestHelpString(const QString&)));	

			}
		}
	}
static void qWinProcessConfigRequests()                // perform requests in queue
{
    if (!configRequests)
        return;
    QWinConfigRequest *r;
    for (;;) {
        if (configRequests->isEmpty())
            break;
        r = configRequests->takeLast();
        QWidget *w = QWidget::find(r->id);
        QRect rect(r->x, r->y, r->w, r->h);
        int req = r->req;
        delete r;

        if ( w ) {                              // widget exists
            if (w->testAttribute(Qt::WA_WState_ConfigPending))
                return;                         // biting our tail
            if (req == 0)
                w->move(rect.topLeft());
            else if (req == 1)
                w->resize(rect.size());
            else
                w->setGeometry(rect);
        }
    }
    delete configRequests;
    configRequests = 0;
}
Example #6
0
void Animator::timerEvent(QTimerEvent *event){
    vX += accelerationX;
    vY += accelerationY;
    for(int i=data.length()-1; i>=0; i--){
        QWidget* w = data.at(i).first;
        QPoint p = w->pos();
        int end = 2;
        if((vX > 0 && p.x() + (int) vX < data.at(i).second.x() )||
           (vX < 0 && p.x() + (int) vX > data.at(i).second.x()))
            p.setX(p.x()+ (int) vX);
        else{
            p.setX(data.at(i).second.x());
            end--;
        }

        if((vY > 0 && p.y() + (int) vY < data.at(i).second.y() )||
           (vY < 0 && p.y() + (int) vY > data.at(i).second.y()))
            p.setY(p.y()+ (int) vY);
        else{
            p.setY(data.at(i).second.y());
            end--;
        }
        w->move(p);
        if(end==0){
            data.removeAt(i);
        }
    }
    if(data.length()==0){
        this->setup();
        emit ended();
    }
}
void SwitchLayout::addAnimation()
{
    // make sure that the highlighted item can be displayed in view after app startss
    m_ListWidget->scrollToItem(m_ListWidget->item(m_CurrentIndexOfKeyBoard));
    // the following codes are about animation
    contentY = m_ListWidget->itemWidget(m_ListWidget->item(0))->y();
    m_Animation = new QVariantAnimation(m_ListWidget);
    m_Animation->setDuration(70);

    // when currentrow changes, check if new_contentY is different from contentY. If different,m_animation should start
    connect(m_ListWidget, &QListWidget::currentRowChanged,
    this, [this] {
        int new_contentY = m_ListWidget->itemWidget(m_ListWidget->item(0))->y();
        if (new_contentY != contentY  && m_KeyboardList.length() > 5)
        {
            m_Animation->setStartValue(QVariant::fromValue(contentY));
            m_Animation->setEndValue(QVariant::fromValue(new_contentY));

            contentY = new_contentY;

            m_Animation->start();
        }
    });

    connect(m_Animation, &QVariantAnimation::valueChanged, this, [this](const QVariant & value) {
        int contentY = m_ListWidget->itemWidget(m_ListWidget->item(0))->y();
        for (int i = 0; i < m_KeyboardList.length(); i++) {
            QWidget *w = m_ListWidget->itemWidget(m_ListWidget->item(i));
            w->move(0, w->y() - contentY + value.toInt());
        }
    });
}
Example #8
0
Widgets::Widgets(QWidget *parent = 0) : QWidget(parent)
{
	creerFenetreCalendrier();
	creerFenetreCalculatrice();
	creerFenetreChronometre();

	aireCentrale = new QMdiArea;
		aireCentrale->addSubWindow(fenetreCalendrier);
		aireCentrale->addSubWindow(fenetreCalculatrice);
		aireCentrale->addSubWindow(fenetreChronometre);
		aireCentrale->cascadeSubWindows();

	QPushButton *vueCascade = new QPushButton;
		vueCascade->setIcon(QIcon(":/icones/widgets/vueCascade.png"));
		vueCascade->setToolTip("Afficher les sous-fenêtres en cascade");
		connect(vueCascade, SIGNAL(clicked()), aireCentrale, SLOT(cascadeSubWindows()));

	QPushButton *vueTuile = new QPushButton;
		vueTuile->setIcon(QIcon(":/icones/widgets/vueTuiles.png"));
		vueTuile->setToolTip("Afficher les sous-fenêtres en tuile");
		connect(vueTuile, SIGNAL(clicked()), aireCentrale, SLOT(tileSubWindows()));

	QVBoxLayout *layoutOptions = new QVBoxLayout;
		layoutOptions->addWidget(vueCascade);
		layoutOptions->addWidget(vueTuile);
		layoutOptions->setContentsMargins(0, 0, 0, 0);

	QWidget *widgetOptions = new QWidget(aireCentrale);
		widgetOptions->setLayout(layoutOptions);
		widgetOptions->move(10, 10);

	QVBoxLayout *layoutCentral = new QVBoxLayout(this);
		layoutCentral->addWidget(aireCentrale);
		layoutCentral->setContentsMargins(0, 0, 0, 0);
}
Example #9
0
	WindowPlayback(){
		wnd.resize(250, 50);
		wnd.move(300, 100);
		wnd.setWindowTitle("Playback");
		wnd.setToolTip("QWidget");
		wnd.show();
	}
Example #10
0
	WindowOptions(){
		wnd.resize(350, 350);
		wnd.move(300, 500);
		wnd.setWindowTitle("Options");
		wnd.setToolTip("QWidget");
		wnd.show();
	}
Example #11
0
void KSystemTray::minimizeRestore(bool restore)
{
    QWidget *pw = parentWidget();
    if(!pw)
        return;
#ifdef Q_WS_X11
    KWin::WindowInfo info = KWin::windowInfo(pw->winId(), NET::WMGeometry | NET::WMDesktop);
    if(restore)
    {
        if(d->on_all_desktops)
            KWin::setOnAllDesktops(pw->winId(), true);
        else
            KWin::setCurrentDesktop(info.desktop());
        pw->move(info.geometry().topLeft()); // avoid placement policies
        pw->show();
        pw->raise();
        KWin::activateWindow(pw->winId());
    }
    else
    {
        d->on_all_desktops = info.onAllDesktops();
        pw->hide();
    }
#endif
}
Example #12
0
	WindowController(){
		wnd.resize(250, 150);
		wnd.move(300, 300);
		wnd.setWindowTitle("Controller");
		wnd.setToolTip("QWidget");
		wnd.show();
	}
void SyszuxIM::updateHandler(int type)
{
    switch(type)
    {
    case QWSInputMethod::FocusIn:
    {
        QWidget *currentWidget = new QWidget;
        QWidget *parentWidget = new QWidget;
        currentWidget = QApplication::focusWidget();
        parentWidget = currentWidget->parentWidget();
        QPoint globalPoint (currentWidget->mapToGlobal(QPoint(0,0)));             //  获取控件在窗体中的坐标
        QPoint parentGlobalPoint (parentWidget->mapToGlobal(QPoint(0,0)));
        if ( globalPoint.ry() > 239)                     //输入法遮挡了当前要输入的窗口部件
        {
            widgetMoveY = globalPoint.ry() - 239 + parentGlobalPoint.ry();

            parentWidget->move(0,-widgetMoveY);
            // qDebug() << "move"<<(-widgetMoveY);
        }

        syszuxpinyin->show();
    }
    break;

    case QWSInputMethod::FocusOut:
    {

        syszuxpinyin->hide();
    }
    break;
    default:
        break;
    }

}
Example #14
0
Menu::Menu(QWidget *parent) : MenuWidget(parent)
{
    QPalette palette(this->palette());
    palette.setColor(QPalette::Background, Qt::white);
    this->setAutoFillBackground(true);
    this->setPalette(palette);
    this->glView = static_cast<GLScene*>( parent );
    this->setWindowFlags(Qt::WindowStaysOnTopHint);

    this->layout = new QStackedLayout;
    this->layout->setAlignment(Qt::AlignCenter);

    // Main menu widget
    QWidget* main = new QWidget;
    this->mainLayout = new QVBoxLayout(main);
    this->mainLayout->setAlignment(Qt::AlignCenter);
    this->mainLayout->setSpacing(20);
    this->mainLayout->setContentsMargins(0, 30, 0, 0);
    main->move(this->geometry().center());
    buttons[0] = new QPushButton(tr("Select Model"));
    buttons[0]->setMaximumWidth(120);
    mainLayout->addWidget(buttons[0]);
    buttons[1] = new QPushButton(tr("Quit"));
    buttons[1]->setMaximumWidth(120);
    mainLayout->addWidget(buttons[1]);

    // Set up stacked menu
    this->layout->addWidget(main);

    this->layout->setCurrentIndex(0);
    this->setLayout(layout);

    this->setConnections();
}
Example #15
0
	WindowTimeline(){
		wnd.resize(500, 100);
		wnd.move(600, 100);
		wnd.setWindowTitle("Timeline");
		wnd.setToolTip("QWidget");
		wnd.show();
	}
Example #16
0
	WindowSlider(){
		wnd.resize(250, 500);
		wnd.move(600, 300);
		wnd.setWindowTitle("Sliders");
		wnd.setToolTip("QWidget");
		wnd.show();
	}
Example #17
0
/*
 * resizeEvent is to resize mainWindow and put search box to center
 * */
void MainWindow::resizeEvent(QResizeEvent *event) {
    QMainWindow::resizeEvent(event);
    QWidget *central = centralWidget();
    QWidget *layoutContainer = central->findChild<QWidget *>("layoutContainer");
    layoutContainer->move(QPoint((central->width() - layoutContainer->width()) / 2,
                                 (central->height() - layoutContainer->height()) / 2));
}
Example #18
0
bool AppInit::eventFilter(QObject *obj, QEvent *evt)
{
    QWidget *w = (QWidget *)obj;
    if (!w->property("CanMove").toBool()) {
        return QObject::eventFilter(obj, evt);
    }

    QMouseEvent *event = static_cast<QMouseEvent *>(evt);
    if (event->type() == QEvent::MouseButtonPress) {
        if (event->button() == Qt::LeftButton) {
            mousePressed = true;
            mousePoint = event->globalPos() - w->pos();
            return true;
        }
    } else if (event->type() == QEvent::MouseButtonRelease) {
        mousePressed = false;
        return true;
    } else if (event->type() == QEvent::MouseMove) {
        if (mousePressed && (event->buttons() && Qt::LeftButton)) {
            w->move(event->globalPos() - mousePoint);
            return true;
        }
    }

    return QObject::eventFilter(obj, evt);
}
Example #19
0
/**
 * Override the QWidget's move(pos) method to move the wrapper window instead.
 */
void MdiSubWindow::move(const QPoint& pos)
{
  QWidget* pw = getWrapperWindow();
  if (pw)
  {
    pw->move( pos );
  }
}
Example #20
0
/**
 * Override the QWidget's move(x,y) method to move the wrapper window instead.
 */
void MdiSubWindow::move(int x, int y)
{
  QWidget* pw = getWrapperWindow();
  if (pw)
  {
    pw->move( x, y );
  }
}
Example #21
0
void center(QWidget &widget, int w, int h) {
  QDesktopWidget *desktop = QApplication::desktop();
  int screenWidth = desktop->width();
  int screenHeight = desktop->height();
  int x = (screenWidth - w) / 2;
  int y = (screenHeight - h) / 2;
  widget.move(x,y);
}
void tst_QWidget_window::tst_move_show()
{
    QWidget w;
    w.move(100, 100);
    w.show();
    QCOMPARE(w.pos(), QPoint(100, 100));
//    QCoreApplication::processEvents(QEventLoop::AllEvents, 3000);
}
void QDesignerMimeData::moveDecoration(const QPoint &globalPos) const
{
    const QPoint relativeDistance = globalPos - m_globalStartPos;
    const QDesignerDnDItems::const_iterator cend = m_items.constEnd();
    for (QDesignerDnDItems::const_iterator it =m_items.constBegin(); it != cend; ++it ) {
        QWidget *w = (*it)->decoration();
        w->move(w->pos() + relativeDistance);
    }
}
Example #24
0
void center(QWidget & widget)
{
    QRect windowSize = QApplication::desktop() -> frameGeometry();

    int x = (windowSize.width() - widget.frameGeometry().width()) / 2;
    int y = (windowSize.height() - widget.frameGeometry().height()) / 2;

    widget.move(x, y);
}
Example #25
0
void
OCRuler::move(double x, double y)
{
	// Temporarily detach the slider and move it appropriately.
	QWidget *child = detachChild();
	OCDataWidget::move(x, y);
	child->move(int(x) + off_x, int(y) + off_y);
	attachChild(child);
}
Example #26
0
void ClientFrame::placeItemsInTitlebar(QHash<int, QWidget*>* left,
        QHash<int, QWidget*>* center, QHash<int, QWidget*>* right) {
    Config* cfg  = Config::getInstance();
    QHash<int, QWidget*>::iterator i;

    // Colocamos los elementos del área izquierda
    int leftMargin = cfg->getLeftBorderWidth() + 2;
    for (i=left->begin(); i!=left->end(); i++)
    {
        QWidget* w = i.value();
        w->move(leftMargin, w->y());
        leftMargin += w->width();
    }

    // Colocamos los elementos del área derecha
    int rightMargin = this->width() - cfg->getRightBorderWidth() - 2;
    for (i=right->end()-1; i!=right->begin()-1; i--) {
        QWidget* w = i.value();
        rightMargin -= w->width();
        w->move(rightMargin, w->y());
    }

    // Colocamos los elementos del centro
    int centralAreaSize = rightMargin - leftMargin;

    int centralItemsSize = 0;
    for (i=center->begin(); i!=center->end(); i++) {
        QWidget* w = i.value();
        centralItemsSize += w->width();
    }

    int centralMargin;
    if(centralAreaSize > centralItemsSize) {
        centralMargin = leftMargin + (centralAreaSize/2 - centralItemsSize/2);
    } else {
        centralMargin = leftMargin + 5;
    }

    for (i=center->begin(); i!=center->end(); i++) {
        QWidget* w = i.value();
        w->move(centralMargin, w->y());
        centralMargin += w->width();
    }
}
Example #27
0
void TPanelTitleBar::resizeEvent(QResizeEvent *e) {
  QWidget::resizeEvent(e);
  int i;
  for (i = 0; i < (int)m_buttons.size(); i++) {
    QPoint p   = m_buttons[i].first;
    QWidget *w = m_buttons[i].second;
    if (p.x() < 0) p.setX(p.x() + width());
    w->move(p);
  }
}
Example #28
0
void MyScrollArea::updateWidgetPosition()
{
//! [0]
    int hvalue = horizontalScrollBar()->value();
    int vvalue = verticalScrollBar()->value();
    QPoint topLeft = viewport()->rect().topLeft();

    widget->move(topLeft.x() - hvalue, topLeft.y() - vvalue);
//! [0]
}
Example #29
0
FormWindowDnDItem::FormWindowDnDItem(QDesignerDnDItemInterface::DropType type, FormWindow *form,
                                        QWidget *widget, const QPoint &global_mouse_pos)
    : QDesignerDnDItem(type, form)
{
    QWidget *decoration = decorationFromWidget(widget);
    QPoint pos = widget->mapToGlobal(QPoint(0, 0));
    decoration->move(pos);

    init(0, widget, decoration, global_mouse_pos);
}
void QLabelMouseTracking::moveWidget(QMouseEvent *ev, QLabel *label)
{
    QWidget *mainWidget = label->parentWidget();
    QPoint globalPoint = label->mapToGlobal( ev->globalPos() );


    QRect geo = mainWidget->geometry();
    mainWidget->move(geo.x() + ev->x() - this->mousePressedGlobalX,
                     geo.y() + ev->y() - this->mousePressedGlobalY);
}