Results 1 to 20 of 26

Thread: setVisible, -> token, problems

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    So, I don't understand why it doesn't work in my case
    Because you don't know the C++ syntax.
    Before using Qt, you should learn C++, and the first step is learning the systax.
    You can't code if you don't know the sytax.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    I know C++, coauthored many (console) programs. Syntax is very wide definition. I know syntax, but I don't understand why it doesn't work (Don't say: "It means that you don't knot the syntax")

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    ok, then post ui_Dialog.h code here and I'll show you why it doesn't work when you use Dialog->something(). (all though wysota already answered that)
    Syntax is very wide definition
    No, its not, its very specific.
    http://en.wikipedia.org/wiki/Syntax
    and for programming:
    http://en.wikipedia.org/wiki/Syntax_...ming_languages
    Last edited by high_flyer; 12th June 2007 at 12:47.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    Ok, here it goes:
    /************************************************** ******************************
    ** Form generated from reading ui file 'Dialog.ui'
    **
    ** Created: Mon 11. Jun 11:28:37 2007
    ** by: Qt User Interface Compiler version 4.2.3
    **
    ** WARNING! All changes made in this file will be lost when recompiling ui file!
    ************************************************** ******************************/

    #ifndef UI_DIALOG_H
    #define UI_DIALOG_H

    #include <QtCore/QVariant>
    #include <QtGui/QAction>
    #include <QtGui/QApplication>
    #include <QtGui/QButtonGroup>
    #include <QtGui/QDialog>
    #include <QtGui/QGroupBox>
    #include <QtGui/QLabel>
    #include <QtGui/QLineEdit>
    #include <QtGui/QPushButton>
    #include <QtGui/QRadioButton>

    class Ui_Dialog
    {
    public:
    QGroupBox *groupBox;
    QRadioButton *beaufortBox;
    QRadioButton *knotBox;
    QRadioButton *kphBox;
    QRadioButton *mphBox;
    QRadioButton *mpsBox;
    QGroupBox *groupBox_2;
    QRadioButton *beaufortBox_2;
    QRadioButton *knotBox_2;
    QRadioButton *mpsBox_2;
    QRadioButton *kphBox_2;
    QRadioButton *mphBox_2;
    QLabel *label;
    QLabel *salazaarLabel;
    QLabel *fromLabel;
    QLabel *whiteLabel;
    QLabel *toLabel;
    QLineEdit *fromLineEdit;
    QPushButton *convertButton;
    QPushButton *exitButton;
    QPushButton *exitButton_2;
    QPushButton *nextStepButton;

    void setupUi(QDialog *Dialog)
    {
    Dialog->setObjectName(QString::fromUtf8("Dialog"));
    Dialog->setWindowIcon(QIcon(QString::fromUtf8(":/new/prefix1/MainDialogIcon.jpg")));
    groupBox = new QGroupBox(Dialog);
    groupBox->setObjectName(QString::fromUtf8("groupBox"));
    groupBox->setGeometry(QRect(50, 40, 120, 131));
    beaufortBox = new QRadioButton(groupBox);
    beaufortBox->setObjectName(QString::fromUtf8("beaufortBox")) ;
    beaufortBox->setGeometry(QRect(10, 20, 83, 18));
    knotBox = new QRadioButton(groupBox);
    knotBox->setObjectName(QString::fromUtf8("knotBox"));
    knotBox->setGeometry(QRect(10, 40, 83, 18));
    kphBox = new QRadioButton(groupBox);
    kphBox->setObjectName(QString::fromUtf8("kphBox"));
    kphBox->setGeometry(QRect(10, 80, 83, 18));
    mphBox = new QRadioButton(groupBox);
    mphBox->setObjectName(QString::fromUtf8("mphBox"));
    mphBox->setGeometry(QRect(10, 100, 83, 18));
    mpsBox = new QRadioButton(groupBox);
    mpsBox->setObjectName(QString::fromUtf8("mpsBox"));
    mpsBox->setGeometry(QRect(10, 60, 83, 18));
    groupBox_2 = new QGroupBox(Dialog);
    groupBox_2->setObjectName(QString::fromUtf8("groupBox_2"));
    groupBox_2->setGeometry(QRect(240, 40, 120, 131));
    beaufortBox_2 = new QRadioButton(groupBox_2);
    beaufortBox_2->setObjectName(QString::fromUtf8("beaufortBox_2")) ;
    beaufortBox_2->setGeometry(QRect(10, 20, 83, 18));
    knotBox_2 = new QRadioButton(groupBox_2);
    knotBox_2->setObjectName(QString::fromUtf8("knotBox_2"));
    knotBox_2->setGeometry(QRect(10, 40, 83, 18));
    mpsBox_2 = new QRadioButton(groupBox_2);
    mpsBox_2->setObjectName(QString::fromUtf8("mpsBox_2"));
    mpsBox_2->setGeometry(QRect(10, 60, 83, 18));
    kphBox_2 = new QRadioButton(groupBox_2);
    kphBox_2->setObjectName(QString::fromUtf8("kphBox_2"));
    kphBox_2->setGeometry(QRect(10, 80, 83, 18));
    mphBox_2 = new QRadioButton(groupBox_2);
    mphBox_2->setObjectName(QString::fromUtf8("mphBox_2"));
    mphBox_2->setGeometry(QRect(10, 100, 83, 18));
    label = new QLabel(Dialog);
    label->setObjectName(QString::fromUtf8("label"));
    label->setGeometry(QRect(80, 20, 71, 16));
    salazaarLabel = new QLabel(Dialog);
    salazaarLabel->setObjectName(QString::fromUtf8("salazaarLabel")) ;
    salazaarLabel->setGeometry(QRect(20, 410, 275, 16));
    salazaarLabel->setAutoFillBackground(false);
    salazaarLabel->setFrameShape(QFrame::StyledPanel);
    salazaarLabel->setFrameShadow(QFrame::Plain);
    salazaarLabel->setTextFormat(Qt::AutoText);
    salazaarLabel->setScaledContents(false);
    fromLabel = new QLabel(Dialog);
    fromLabel->setObjectName(QString::fromUtf8("fromLabel"));
    fromLabel->setGeometry(QRect(100, 270, 81, 16));
    whiteLabel = new QLabel(Dialog);
    whiteLabel->setObjectName(QString::fromUtf8("whiteLabel"));
    whiteLabel->setGeometry(QRect(190, 270, 46, 14));
    toLabel = new QLabel(Dialog);
    toLabel->setObjectName(QString::fromUtf8("toLabel"));
    toLabel->setGeometry(QRect(270, 270, 97, 16));
    fromLineEdit = new QLineEdit(Dialog);
    fromLineEdit->setObjectName(QString::fromUtf8("fromLineEdit") );
    fromLineEdit->setGeometry(QRect(40, 270, 51, 20));
    convertButton = new QPushButton(Dialog);
    convertButton->setObjectName(QString::fromUtf8("convertButton")) ;
    convertButton->setGeometry(QRect(200, 320, 75, 23));
    exitButton = new QPushButton(Dialog);
    exitButton->setObjectName(QString::fromUtf8("exitButton"));
    exitButton->setGeometry(QRect(300, 320, 75, 23));
    exitButton_2 = new QPushButton(Dialog);
    exitButton_2->setObjectName(QString::fromUtf8("exitButton_2") );
    exitButton_2->setGeometry(QRect(290, 190, 75, 23));
    nextStepButton = new QPushButton(Dialog);
    nextStepButton->setObjectName(QString::fromUtf8("nextStepButton") );
    nextStepButton->setGeometry(QRect(160, 190, 91, 23));

    retranslateUi(Dialog);

    QSize size(400, 426);
    size = size.expandedTo(Dialog->minimumSizeHint());
    Dialog->resize(size);

    QObject::connect(exitButton, SIGNAL(clicked()), Dialog, SLOT(close()));
    QObject::connect(exitButton_2, SIGNAL(clicked()), Dialog, SLOT(close()));

    QMetaObject::connectSlotsByName(Dialog);
    } // setupUi

    void retranslateUi(QDialog *Dialog)
    {
    Dialog->setWindowTitle(QApplication::translate("Dialog" , "Wind units converter", 0, QApplication::UnicodeUTF8));
    groupBox->setTitle(QApplication::translate("Dialog", "From", 0, QApplication::UnicodeUTF8));
    beaufortBox->setText(QApplication::translate("Dialog", "Beaufort", 0, QApplication::UnicodeUTF8));
    knotBox->setText(QApplication::translate("Dialog", "Knot", 0, QApplication::UnicodeUTF8));
    kphBox->setText(QApplication::translate("Dialog", "Kph", 0, QApplication::UnicodeUTF8));
    mphBox->setText(QApplication::translate("Dialog", "Mph", 0, QApplication::UnicodeUTF8));
    mpsBox->setText(QApplication::translate("Dialog", "Mps", 0, QApplication::UnicodeUTF8));
    groupBox_2->setTitle(QApplication::translate("Dialog", "To", 0, QApplication::UnicodeUTF8));
    beaufortBox_2->setText(QApplication::translate("Dialog", "Beaufort", 0, QApplication::UnicodeUTF8));
    knotBox_2->setText(QApplication::translate("Dialog", "Knot", 0, QApplication::UnicodeUTF8));
    mpsBox_2->setText(QApplication::translate("Dialog", "Mps", 0, QApplication::UnicodeUTF8));
    kphBox_2->setText(QApplication::translate("Dialog", "Kph", 0, QApplication::UnicodeUTF8));
    mphBox_2->setText(QApplication::translate("Dialog", "Mph", 0, QApplication::UnicodeUTF8));
    label->setText(QApplication::translate("Dialog", "Convert units:", 0, QApplication::UnicodeUTF8));
    salazaarLabel->setText(QApplication::translate("Dialog", "Salazaar Software Corporation - Speed Units Converter", 0, QApplication::UnicodeUTF8));
    fromLabel->setText(QApplication::translate("Dialog", "Beaufort(s) it's", 0, QApplication::UnicodeUTF8));
    whiteLabel->setText(QString());
    toLabel->setText(QApplication::translate("Dialog", "Meter(s) per second", 0, QApplication::UnicodeUTF8));
    convertButton->setText(QApplication::translate("Dialog", "Convert", 0, QApplication::UnicodeUTF8));
    exitButton->setText(QApplication::translate("Dialog", "Exit", 0, QApplication::UnicodeUTF8));
    exitButton_2->setText(QApplication::translate("Dialog", "Exit", 0, QApplication::UnicodeUTF8));
    nextStepButton->setText(QApplication::translate("Dialog", "Go to next step", 0, QApplication::UnicodeUTF8));
    Q_UNUSED(Dialog);
    } // retranslateUi

    };

    namespace Ui {
    class Dialog: public Ui_Dialog {};
    } // namespace Ui

    #endif // UI_DIALOG_H

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    right:
    So lets see:
    Qt Code:
    1. void setupUi(QDialog *Dialog)
    2. {
    3. Dialog->setObjectName(QString::fromUtf8("Dialog"));
    4. // the rest
    5. }
    6.  
    7. //and your code:
    8. bool Dialog::settingUp()
    9. {
    10. ...
    11. Dialog->setWindowTitle("Converting value from Beaufort to Knot");
    12. ....
    13. }
    To copy to clipboard, switch view to plain text mode 
    Now, since you know C++ syntax, why don't you explain to me the error in your code.
    If you can't I will.


    coauthored many (console) programs.
    I'd be interested to know which ones, would be great if you could supply links.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    Quote Originally Posted by high_flyer View Post
    right:
    So lets see:
    Qt Code:
    1. void setupUi(QDialog *Dialog)
    2. {
    3. Dialog->setObjectName(QString::fromUtf8("Dialog"));
    4. // the rest
    5. }
    6.  
    7. //and your code:
    8. bool Dialog::settingUp()
    9. {
    10. ...
    11. Dialog->setWindowTitle("Converting value from Beaufort to Knot");
    12. ....
    13. }
    To copy to clipboard, switch view to plain text mode 
    Now, since you know C++ syntax, why don't you explain to me the error in your code.
    If you can't I will.
    How do you think, why am I asking this question? Obviously because I don't know the answer
    Quote Originally Posted by high_flyer View Post
    I'd be interested to know which ones, would be great if you could supply links.
    Important? But if you want to know, one was called Professional Friends Database with many useful functions. I don't supply link, because pure C++ programs are history...

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    How do you think, why am I asking this question? Obviously because I don't know the answer
    Well, if you don't know the answer, how can you claim you know C++ syntax?

    If you knew C++ then you would know that:
    Qt Code:
    1. void setupUi(QDialog *Dialog) //<< 'Dialog' pointer is defined.
    2. {
    3.  
    4. Dialog->setObjectName(QString::fromUtf8("Dialog")); //so this is ok.
    5. // the rest
    6. }
    To copy to clipboard, switch view to plain text mode 

    And as wasota gave the answer above:
    Qt Code:
    1. bool Dialog::settingUp() //Dialog is the name of the class
    2. {
    3. ...
    4. Dialog->setWindowTitle("Converting value from Beaufort to Knot"); //pointer 'Dialog' never defined, so Dialog-> is illegal.
    5. ....
    6. }
    To copy to clipboard, switch view to plain text mode 

    I don't supply link, because pure C++ programs are history...
    History??
    What do you mean?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

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

    Default Re: setVisible, -> token, problems

    Quote Originally Posted by Salazaar View Post
    I know syntax, but I don't understand why it doesn't work (Don't say: "It means that you don't knot the syntax")
    Based on what I've seen in your posts, I strongly doubt that...

    Quote Originally Posted by Salazaar View Post
    Ok, here it goes:
    Next time please attach large amounts of code instead of pasting them directly.

    Quote Originally Posted by Salazaar View Post
    I don't supply link, because pure C++ programs are history...
    Well now... I... wouldn't say that....

  9. #9
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    How never defined?? It was defined in first code - QDialog * Dialog. So what's "legal"?
    I mean that console program doesn't exist, and I'm not programming purely in C++ but using Qt
    edit:
    wysota, I meant purely C++, without Qt

  10. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    It was defined in first code - QDialog * Dialog. So what's "legal"?
    Heh???
    I don't see that nowhere in your code!
    And neither the compiler, so I guess you didn't define QDialog * Dialog.
    And in general, even if you have, its bad practice to use the class name as variable name, since it might confuse the compiler.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  11. #11
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    Lets review
    Qt Code:
    1. void setupUi(QDialog *Dialog)
    To copy to clipboard, switch view to plain text mode 
    So it should work, even if the name is the same as class name

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

    Default Re: setVisible, -> token, problems

    Quote Originally Posted by Salazaar View Post
    wysota, I meant purely C++, without Qt
    Yes, I meant that as well. 99% of your problems on this forum are C++ syntax problems and not Qt. You can't distinguish between static and non-static methods, objects and classes, you admitted you can't handle subclassing very well, you have problems with understanding scopes and you can't spot a difference between a declaration of an object and a method. All these problems have nothing to do with Qt, they are purely C++ related. Qt is not a language, it's a bunch of classes conforming to the C++ syntax (apart from the "signals", "slots" and "emit" keywords, but these are transparent to C++ compilers).

  13. #13
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    So it should work, even if the name is the same as class name
    No it should not.
    Because the decleration does not belong to the scope you are using it in.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  14. #14
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    Understood. Assuming, what do I have to change in this Dialog->setWindowTitle to make it no-errormaking program?

  15. #15
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: setVisible, -> token, problems

    Define a QDialog pointer instead of Dialog.

    Allthough the above is the answer to your question, it will not solve your problem, which is knowing and understanding C++ rules and syntax.
    As long as you wont master that, you will have these problems all the time.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  16. #16
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: setVisible, -> token, problems

    Quote Originally Posted by high_flyer View Post
    Define a QDialog pointer instead of Dialog.
    I don't understand, Dialog is a pointer of QDIalog

Similar Threads

  1. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19
  2. Problems
    By euthymos in forum Installation and Deployment
    Replies: 2
    Last Post: 13th June 2006, 19:11

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.