Results 1 to 20 of 20

Thread: problem in window to enter information

  1. #1
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default problem in window to enter information

    Hi,
    i want when clic in button i see window where i enter name and number

    i make like that
    Qt Code:
    1. Add = new QToolButton(page_13);
    2. Add->setObjectName(QString::fromUtf8("Add"));
    3. Add->setGeometry(QRect(150, 9, 51, 31));
    4. Add->setText("Aadd");
    5. connect(Add, SIGNAL(clicked()),mQOgreWidget,SLOT(AddInfo()));
    To copy to clipboard, switch view to plain text mode 
    in AddInfo() i make like that
    Qt Code:
    1. QString Nom_Segment = QInputDialog::getText(this, "Name", "Name");
    2. int entier = QInputDialog::getInteger(this, "Number", "Number");
    To copy to clipboard, switch view to plain text mode 
    But like that i see one window where i enter just the name when i close it i see another one where i enter the number

    BUT it's not what i want i want to enter the a both in one window

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Implement a dialog that will contain both fields.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    Implement a dialog that will contain both fields.
    how i do that ?

    did you mean that i define new widget with 2 QLineEdit,layout ?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Quote Originally Posted by robelle View Post
    how i do that ?
    A good place to start would be to do any tutorial on Qt that is based on QDialog.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    ok
    as i see here
    http://doc.qt.digia.com/4.6/dialogs-extension.html
    the qdialog in my case will be a widget


    Added after 57 minutes:


    I have just another question
    i make like that
    Qt Code:
    1. connect(Add, SIGNAL(clicked()),mQOgreWidget,SLOT(showdialogue()));
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. void MainWindow::showdialogue()
    2. {
    3. QWidget fenetre;
    4.  
    5. QLineEdit *nom = new QLineEdit;
    6. QLineEdit *nombre = new nombre;
    7.  
    8. QFormLayout *layout = new QFormLayout;
    9. layout->addRow("nom", nom);
    10. layout->addRow("nombre", nombre);
    11.  
    12. fenetre.setLayout(layout);
    13.  
    14. fenetre.show();
    To copy to clipboard, switch view to plain text mode 
    my question is : the widget fenêtre i must define it in another class ?
    Last edited by robelle; 2nd October 2012 at 10:06.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Quote Originally Posted by robelle View Post
    ok
    as i see here
    http://doc.qt.digia.com/4.6/dialogs-extension.html
    the qdialog in my case will be a widget
    That's not a good tutorial. Start with the Addressbook tutorial.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    robelle (2nd October 2012)

  8. #7
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    ok i make like that
    i create new class "formulaire_segment"
    "add_segment.h"
    Qt Code:
    1. #ifndef FORMULAIRE_SEGMENT_H
    2. #define FORMULAIRE_SEGMENT_H
    3.  
    4.  
    5. #include <QWidget>
    6. #include <QLineEdit>
    7. #include <QtGui>
    8.  
    9. class formulaire_segment : public QWidget
    10. {
    11. Q_OBJECT
    12.  
    13. public :
    14. formulaire_segment();
    15.  
    16. private:
    17. QLineEdit *nom;
    18. QLineEdit *nombre;
    19. QLabel *nom_segment;
    20. QLabel *nombre_points;
    21. QPushButton *Bouton;
    22. };
    23.  
    24. #endif
    To copy to clipboard, switch view to plain text mode 
    add_segment.cpp
    Qt Code:
    1. #include"formulaire_segment.h"
    2.  
    3. formulaire_segment::formulaire_segment():QWidget()
    4. {
    5. setFixedSize(440, 140);
    6. //creation des labels
    7. nom_segment=new QLabel("nom_segment");
    8. nombre_points=new QLabel("nombre_points");
    9.  
    10. //creation des edit
    11. nom= new QLineEdit("", this);
    12. nom->setGeometry(310, 15, 30, 30);
    13.  
    14. nombre= new QLineEdit("", this);
    15. nombre->setGeometry(260, 55, 30, 30);
    16. }
    To copy to clipboard, switch view to plain text mode 

    in the mainwindows
    Qt Code:
    1. class formulaire_segment;
    2. class MainWindow : public QMainWindow
    3. {
    4. Q_OBJECT
    5. public:
    6. MainWindow();
    7. public slots:
    8. void showdialogue();
    To copy to clipboard, switch view to plain text mode 
    and
    Qt Code:
    1. AddSegm = new QToolButton(page_13);
    2. AddSegm->setObjectName(QString::fromUtf8("AddSegm"));
    3. AddSegm->setGeometry(QRect(150, 9, 51, 31));
    4. AddSegm->setText("Ajouter Segment");
    5. connect(AddSegm, SIGNAL(clicked()),mQOgreWidget,SLOT(showdialogue()));
    6.  
    7. //////////////////////////////*showdialogue slot///////////////////////////////////
    8. void MainWindow::showdialogue()
    9. {
    10.  
    11. formulaire_segment *formulaire=new formulaire_segment();
    12.  
    13. formulaire->show();
    14.  
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    BUT when i clic on the button nothing happen i do not see the 2 window

  9. #8
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: problem in window to enter information

    Change this:
    Qt Code:
    1. connect(AddSegm, SIGNAL(clicked()),mQOgreWidget,SLOT(showdialogue()));
    To copy to clipboard, switch view to plain text mode 
    to:
    Qt Code:
    1. connect(AddSegm, SIGNAL(clicked()),this,SLOT(showdialogue()));
    To copy to clipboard, switch view to plain text mode 

  10. The following user says thank you to boudie for this useful post:

    robelle (2nd October 2012)

  11. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Quote Originally Posted by robelle View Post
    ok i make like that
    Please follow the tutorial. In particular, use layouts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    robelle (2nd October 2012)

  13. #10
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    thanks , it work now
    but i do not see the labels

  14. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Because you didn't use layouts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #12
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    i added layout but nothing is happend
    Qt Code:
    1. formulaire_segment::formulaire_segment():QWidget()
    2. {
    3. setFixedSize(440, 140);
    4. //creation des labels
    5. nom_segment=new QLabel("nom_segment");
    6. nom_segment->setFont(QFont("Arial", 20));
    7. nom_segment->setGeometry(20, 20, 440, 20);
    8.  
    9. nombre_points=new QLabel("nombre_points");
    10. nombre_points->setFont(QFont("Arial", 12));
    11. nombre_points->setGeometry(20, 60, 440, 20);
    12.  
    13. //creation des edit
    14. nom= new QLineEdit("", this);
    15. nom->setGeometry(310, 15, 30, 30);
    16.  
    17. nombre= new QLineEdit("", this);
    18. nombre->setGeometry(260, 55, 30, 30);
    19.  
    20. QGridLayout *mainLayout = new QGridLayout;
    21. mainLayout->addWidget(nom_segment, 0, 0);
    22. mainLayout->addWidget(nombre_point, 0, 1);
    23. mainLayout->addWidget(nom, 1, 0);
    24. mainLayout->addWidget(nombre, 1, 1);
    To copy to clipboard, switch view to plain text mode 

  16. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Please follow the tutorial I directed you to instead of blindly trying different things. Currently your layout configuration is incorrect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #14
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    yes i forget
    Qt Code:
    1. setLayout(mainLayout);
    2. setWindowTitle(("formulaire"));
    To copy to clipboard, switch view to plain text mode 

  18. #15
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    it's me again
    i have now problem with signal/slot

    i add this in the file formulaire_segment.h
    Qt Code:
    1. struct segm
    2. {
    3. QString name;
    4. int number;
    5. }S;
    6.  
    7. std::vector<segm> segment;
    8.  
    9.  
    10. public slots :
    11. void saveinfo();
    12. signals:
    13. void formulaire_remplie(std::vector<segm> segme);
    To copy to clipboard, switch view to plain text mode 
    and in the formulaire_segment.cpp
    Qt Code:
    1. formulaire_segment::formulaire_segment():QWidget()
    2. {
    3. setFixedSize(440, 140);
    4. //creation des labels
    5. nom_segment=new QLabel("nom_segment");
    6. nom_segment->setFont(QFont("Arial", 12));
    7. nom_segment->setGeometry(20, 20, 440, 12);
    8.  
    9. nombre_points=new QLabel("nombre_points");
    10. nombre_points->setFont(QFont("Arial", 12));
    11. nombre_points->setGeometry(20, 60, 440, 20);
    12.  
    13. //creation des edit
    14. nom= new QLineEdit("", this);
    15. nom->setGeometry(310, 15, 30, 30);
    16.  
    17. nombre= new QDoubleSpinBox( this);
    18. nombre->setGeometry(260, 55, 30, 30);
    19. nombre->setRange(0, 4);
    20. //
    21. Bouton = new QToolButton(this);
    22. Bouton->setObjectName("Ajouter");
    23. Bouton->setGeometry(QRect(10, 10, 51, 31));
    24. Bouton->setText("Ajouter");
    25.  
    26.  
    27. QGridLayout *mainLayout = new QGridLayout;
    28. mainLayout->addWidget(nom_segment, 0, 0);
    29. mainLayout->addWidget(/*nombre_points*/nom, 0,1);
    30. mainLayout->addWidget(/*nom*/nombre_points, 1, 0);
    31. mainLayout->addWidget(nombre, 1,1);
    32. mainLayout->addWidget(Bouton, 2, 2);
    33. setLayout(mainLayout);
    34. setWindowTitle(tr("formulaire"));
    35.  
    36. connect(Bouton, SIGNAL(clicked()), this, SLOT( saveinfo()));
    37.  
    38.  
    39. }
    40.  
    41. void formulaire_segment:: saveinfo()
    42. {
    43. segm segmente ;
    44.  
    45. segmente.name=nom->text();
    46. segmente.number=nombre->value();
    47. segment.push_back(segmente);
    48. this->hide();
    49. emit formulaire_remplie(segment);
    50.  
    51. }
    To copy to clipboard, switch view to plain text mode 
    in the mainwindow.h i added
    Qt Code:
    1. struct segm
    2. {
    3. QString name;
    4. int number;
    5. }S;
    6. public slots:
    7. void showdialogue();
    8. void formulaire_remplie(std::vector<segm> segme);
    To copy to clipboard, switch view to plain text mode 
    in the .cpp
    Qt Code:
    1. connect(AddSegm, SIGNAL(clicked()),this,SLOT(showdialogue()));
    2. /////////////////////
    3. void MainWindow::showdialogue()
    4. {
    5.  
    6. formulaire_segment *formulaire=new formulaire_segment();
    7.  
    8.  
    9. formulaire->show();
    10.  
    11.  
    12.  
    13.  
    14. }
    15. void MainWindow::formulaire_remplie(std::vector<segm> segme)
    16. {
    17. printf ("je suis dans formulaire");
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 
    BUT when i run the program it does not enter to "formulaire_remplie"

    EDIT

    i adde this line in showdialogue()
    Qt Code:
    1. connect(formulaire,SIGNAL (formulaire_remplie(std::vector<segm> segme)),this,SLOT(formulaire_remplie(std::vector<segm> segme)));
    To copy to clipboard, switch view to plain text mode 
    BUT i still when i run the program he does'nt enter to the function "formulaire_remplie"


    Added after 52 minutes:


    it work now i maked mistake in the connect
    Last edited by robelle; 2nd October 2012 at 17:37.

  19. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    I really suggest you do a couple of simple tutorials before doing anything serious.

    You will solve your problem on your own if you can answer the following question: What are the (three) requirements that needs to be satisfied in order to use signals and slots within a class?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  20. The following user says thank you to wysota for this useful post:

    robelle (2nd October 2012)

  21. #17
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    thanks it work now

  22. #18
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    she is me again

    to save the information (name,number) i amke like that
    Qt Code:
    1. void formulaire_segment:: saveinfo()
    2. {
    3. segm segmente ;
    4.  
    5. segmente.name=nom->text();
    6. segmente.number=nombre->value();
    7. segment.push_back(segmente);
    8. this->hide();
    9. emit formulaire_remplie(segment);
    10. segment.clear();
    11.  
    12. }
    To copy to clipboard, switch view to plain text mode 
    i make segment.clear to return to the zero
    but when i excute the Qdialogue for the seconde time i do not find it empty
    Last edited by robelle; 3rd October 2012 at 08:42.

  23. #19
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: problem in window to enter information

    Quote Originally Posted by robelle View Post
    i make segment.clear to return to the zero
    but when i excute the Qdialogue for the seconde time i do not find it empty
    How does "segment" influence what is shown on the GUI? Do you change the values displayed in the UI based on the segment variable anywhere? I understand you may be a beginner programmer but before doing something you should first think how this something should be done, how it is done and how the two relate to each other.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  24. #20
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: problem in window to enter information

    yes,
    i found that the problem not with my signal
    BUT
    I forget to clear another vector in the slot

    there is no problem now
    thanks

Similar Threads

  1. Replies: 6
    Last Post: 9th November 2011, 04:31
  2. Replies: 0
    Last Post: 20th October 2011, 18:27
  3. Replies: 0
    Last Post: 20th June 2011, 20:28
  4. Replies: 1
    Last Post: 14th September 2008, 23:05
  5. Tab/Enter focus problem
    By b1 in forum Qt Programming
    Replies: 4
    Last Post: 23rd October 2006, 23:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.