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. QLineEdit Matrix, can not select single (QLineEdit) item by clicking
Forum Updated to NodeBB v4.3 + New Features

QLineEdit Matrix, can not select single (QLineEdit) item by clicking

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.6k 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.
  • yczoY Offline
    yczoY Offline
    yczo
    wrote on last edited by yczo
    #1

    Hello all, I have an object that contains some QLineEdit elements.

    My intention is, fill a window with these elements, in the form:
    (0) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
    (1) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
    (2) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
    .
    .
    .
    (19) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]

    [edited]
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        this->setFixedSize(1333,768);
     [/edited]
        getmsg *ind[20];
    
        for (qint8 i = 0; i < 20; i++) {
            ind[i] = new getmsg (this,1333,768,i);
            ind[i]->updatePos(0,i*20);  // Next element 20 below
        }
    

    That works (in theory), the screen is filled with the objects, but when I try to click in a single element, to select it and edit, I can not.
    I can not select a single QLineEdit with the mouse. (Can I select only the QLineEdit elements from the last object)
    No Idea why that happens.

    Please can somebody help me to fix the issue?

    Thanks in advance.
    Greetings

    pd: The getmsg.cpp code

    //getmsg.cpp
    #include "getmsg.h"
    
    getmsg::getmsg(QWidget *parent, int _maxX, int _maxY, qint8 _nMsg)
        : QWidget(parent),maxX(_maxX),maxY(_maxY),nMsg(_nMsg)
    {
        resize(maxX,maxY);
        number = new QLabel(this);
      
        number->setText(QString::number(nMsg));
    
        getChannel = new QLineEdit(this);
        getChannel->resize(wgC,hLine);
    
        getMode = new QLineEdit(this);
        getMode->resize(wgM,hLine);
    
        get_tT = new QLineEdit(this);
        get_tT->resize(wgtT,hLine);
    
    }
    //******************************************************
    void getmsg::updatePos(int px, int py){
    
        px = origX+px;
        py = origY+py;
    
        number->move(px,py);
        px = px + wNumber +gSpace;
        circle->updatePos(px,py);
        px = px + radCircle + 2*gSpace;
        getChannel->move(px,py);
        px = px+wgC+gSpace; //last x origin
        getMode->move(px,py);
        px = px + wgM + gSpace;
        get_tT->move(px,py);
    }
    
    
    ? 1 Reply Last reply
    0
    • yczoY yczo

      Hello all, I have an object that contains some QLineEdit elements.

      My intention is, fill a window with these elements, in the form:
      (0) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
      (1) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
      (2) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]
      .
      .
      .
      (19) [..QLineEdit 1..] [..QLineEdit 2..] [..QLineEdit 3..]

      [edited]
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
          this->setFixedSize(1333,768);
       [/edited]
          getmsg *ind[20];
      
          for (qint8 i = 0; i < 20; i++) {
              ind[i] = new getmsg (this,1333,768,i);
              ind[i]->updatePos(0,i*20);  // Next element 20 below
          }
      

      That works (in theory), the screen is filled with the objects, but when I try to click in a single element, to select it and edit, I can not.
      I can not select a single QLineEdit with the mouse. (Can I select only the QLineEdit elements from the last object)
      No Idea why that happens.

      Please can somebody help me to fix the issue?

      Thanks in advance.
      Greetings

      pd: The getmsg.cpp code

      //getmsg.cpp
      #include "getmsg.h"
      
      getmsg::getmsg(QWidget *parent, int _maxX, int _maxY, qint8 _nMsg)
          : QWidget(parent),maxX(_maxX),maxY(_maxY),nMsg(_nMsg)
      {
          resize(maxX,maxY);
          number = new QLabel(this);
        
          number->setText(QString::number(nMsg));
      
          getChannel = new QLineEdit(this);
          getChannel->resize(wgC,hLine);
      
          getMode = new QLineEdit(this);
          getMode->resize(wgM,hLine);
      
          get_tT = new QLineEdit(this);
          get_tT->resize(wgtT,hLine);
      
      }
      //******************************************************
      void getmsg::updatePos(int px, int py){
      
          px = origX+px;
          py = origY+py;
      
          number->move(px,py);
          px = px + wNumber +gSpace;
          circle->updatePos(px,py);
          px = px + radCircle + 2*gSpace;
          getChannel->move(px,py);
          px = px+wgC+gSpace; //last x origin
          getMode->move(px,py);
          px = px + wgM + gSpace;
          get_tT->move(px,py);
      }
      
      
      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      @yczo Hallo! My first guess would be that your line edits are created before you call setupUi() and thus the central widget covers the line edits and gets all the clicks.

      yczoY 1 Reply Last reply
      1
      • ? A Former User

        @yczo Hallo! My first guess would be that your line edits are created before you call setupUi() and thus the central widget covers the line edits and gets all the clicks.

        yczoY Offline
        yczoY Offline
        yczo
        wrote on last edited by yczo
        #3

        @Wieland Hello Wieland, really the complete code is:

        MainWindow::MainWindow(QWidget *parent) :
            QMainWindow(parent),
            ui(new Ui::MainWindow)
        {
            ui->setupUi(this);
            this->setFixedSize(1333,768);
        
           getmsg *ind[20];
            for (qint8 i = 0; i < 20; i++) {
                ind[i] = new getmsg (this,1333,768,i);
                ind[i]->updatePos(0,i*20);  // Next element 20 below
            }
        

        I did an error in the first post, I`m sorry :-(
        (thank you for answer)

        1 Reply Last reply
        0
        • yczoY Offline
          yczoY Offline
          yczo
          wrote on last edited by
          #4

          Please,
          Any help would be appreciated. Also if the way to create the matrix is wrong, suggestions accepted
          Greetings

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

            Hi,

            Why not use a QVBoxLayout to contain your widgets ?

            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
            1
            • yczoY Offline
              yczoY Offline
              yczo
              wrote on last edited by
              #6

              Thank you, I will take a look... But, with QVBoxLayout, can I too an Object make and multiply on the screen?

              Thank you very much, Greetings

              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