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. QT drag and drop of image size problem after taking multple view port?
Forum Updated to NodeBB v4.3 + New Features

QT drag and drop of image size problem after taking multple view port?

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 860 Views 2 Watching
  • 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.
  • A Offline
    A Offline
    amarism
    wrote on last edited by
    #1

    I am able to drag image from listwidget thumbnail and able to drop image inside the OpenG view port.

    I am creating a new class openGL and class inhert the OpenGLWidget class. By using new class object i am create multiple view port .So, it will accept drop of image.

    For 1 view port i am able to fix the size. But i am extract when i have 10 view port.

    for fixing the size i am using this one code:-

    void openGL::dropEvent(QDropEvent *event)
    {
    	const QMimeData *mimeData = event->mimeData();
    
    	QImage image = qvariant_cast<QImage>(event->mimeData()->imageData());
    
    	if (mimeData->hasFormat("application/x-qabstractitemmodeldatalist")) {
    		QByteArray encoded = mimeData->data("application/x-qabstractitemmodeldatalist");
    		QDataStream stream(&encoded, QIODevice::ReadOnly);
    
    		while (!stream.atEnd()) {
    			int row;
    			int col;
    			QMap<int, QVariant> roleDataMap;
       			stream >> row >> col >> roleDataMap;
      
    			QIcon icon = roleDataMap.value(1).value<QIcon>();
    			
    			m_pixmap = icon.pixmap(icon.availableSizes().first());
    		
    			update();
    		}
    	}
    	else {
    		event->ignore();
    	}
    
    
    void openGL::paintGL()
    {
    	QPainter painter(this);
    	
    	painter.drawPixmap(0,0, m_pixmap.scaled(1000, 500, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation));
    //for single view port i will fix width and height
    }
    

    Any suggestion is very helpful

    Thank you in advance

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Why do you want to fix the size ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Why do you want to fix the size ?

        A Offline
        A Offline
        amarism
        wrote on last edited by
        #3

        @SGaist fixing of size is working but i want to take dynamic size respect to view port .

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It might sound silly, but why not just use the view port size in your scaled call rather than fixed values.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            It might sound silly, but why not just use the view port size in your scaled call rather than fixed values.

            A Offline
            A Offline
            amarism
            wrote on last edited by amarism
            #5

            @SGaist i will try to get the view port size . but it will not passes the actual size .

            int w =((QWidget*)view[0])->width();
            int h = ((QWidget*)view[0])->height();
            

            I will get the grid_layout size though this code :-

                QSize sz = this->ui->gridLayout_8->sizeHint();
            

            but it will pass the only single view port size.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Why not use just size() ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                Just to be sure. you are asking about the SIZE of the openGl widget and not the size of
                the openGl viewport ?
                https://bugreports.qt.io/browse/QTBUG-64635

                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