Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Portuguese
  4. Ajuda Qt::CaseSensitive
Forum Updated to NodeBB v4.3 + New Features

Ajuda Qt::CaseSensitive

Scheduled Pinned Locked Moved Portuguese
4 Posts 2 Posters 3.3k Views 1 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.
  • I Offline
    I Offline
    iij1021
    wrote on last edited by
    #1

    @#ifndef FINDTEST_H
    #define FINDTEST_H
    #include<QCheckBox>
    #include<QLabel>
    #include<QLineEdit>
    #include<QPushButton>
    #include<QString>
    #include<qnamespace.h>
    #include<Qt>

    #include <QDialog>
    class QCheckBox;
    class QLabel;
    class QLineEdit;
    class QPushButton;
    class findtest;

    class findtest : public QDialog
    {
    Q_OBJECT

    public:

    findtest(QWidget *parent = 0);
    

    signals:

    void findNext(const QString &str,Qt::CaseSensitive cs);
    void findPrevious(const QString &str,Qt::CaseSensitive cs);
    

    private slots:

    void findClicked();
    void enableFindButton(const QString &text);
    

    private:

    QLabel *label;
    QLineEdit *lineEdit;
    QCheckBox *caseCheckBox;
    QCheckBox *backwardCheckBox;
    QPushButton *findButton;
    QPushButton *closeButton;
    

    };
    #endif // FINDTEST_H
    @
    aqui esta erro error: C2061: syntax error : identifier 'CaseSensitive'

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TioRoy
      wrote on last edited by
      #2

      Hum.... estranho. Fiz um Ctrl+C Ctrl+V num arquivo .h, e não deu erro algum.

      Testei no QtCreator 2.6.2, com o Qt 4.8.3 (Linux).

      Que versão do Qt você está usando? O erro dá no .h ou no .cpp? Está usando o QtCreator, ou apenas o qmake para o build?

      Talvez o log de compilação ajude.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        iij1021
        wrote on last edited by
        #3

        Header #ifndef FINDTEST_H
        @#define FINDTEST_H
        #include<QCheckBox>
        #include<QLabel>
        #include<QLineEdit>
        #include<QPushButton>
        #include<QString>
        #include<qnamespace.h>
        #include<Qt>* *

        #include <QDialog>
        class QCheckBox;
        class QLabel;
        class QLineEdit;
        class QPushButton;
        class findtest;

        class findtest : public QDialog
        {
        Q_OBJECT

        public:

        findtest(QWidget *parent = 0);
        

        signals:

        void findNext(const QString &str,Qt::CaseSensitive cs);
        void findPrevious(const QString &str,Qt::CaseSensitive cs);
        

        private slots:

        void findClicked();
        void enableFindButton(const QString &text);
        

        private:

        QLabel *label;
        QLineEdit *lineEdit;
        QCheckBox *caseCheckBox;
        QCheckBox *backwardCheckBox;
        QPushButton *findButton;
        QPushButton *closeButton;
        

        };
        #endif // FINDTEST_H

        #include"findtest.h"
        #include<QtCore>
        #include<QHBoxLayout>
        #include<QVBoxLayout>

        findtest::findtest(QWidget *parent) :
        QDialog(parent)
        {
        label = new QLabel(tr("Find &what: "));
        lineEdit = new QLineEdit;
        label->setBuddy(lineEdit);
        caseCheckBox = new QCheckBox(tr("Match&case"));
        backwardCheckBox = new QCheckBox(tr("Search & Backward"));
        findButton = new QPushButton(tr("&Find"));
        findButton->setDefault(true);
        findButton->setEnabled(false);
        closeButton = new QPushButton(tr("&Find"));

        connect(lineEdit,SIGNAL(textChanged(QString &)),
                this,SLOT(enableFindButton(const QString)));
        
        connect(findButton ,SIGNAL(clicked()),
                this,SLOT(findClicked()));
        
        connect(closeButton,SIGNAL(clicked()),
                this,SLOT(close()));
        
        
        QHBoxLayout *topleftLayout = new QHBoxLayout;
        topleftLayout->addWidget(label);
        topleftLayout->addWidget(lineEdit);
        QVBoxLayout *leftLayout = new QVBoxLayout;
        leftLayout->addLayout(topleftLayout);
        leftLayout->addWidget(caseCheckBox);
        leftLayout->addWidget(backwardCheckBox);
        QVBoxLayout *rightLayout = new QVBoxLayout;
        rightLayout->addWidget(findButton);
        rightLayout->addStretch();
        QHBoxLayout *mainLayout = new QHBoxLayout;
        mainLayout->addLayout(leftLayout);
        mainLayout->addLayout(rightLayout);
        setLayout(mainLayout);
        
        setWindowTitle(tr("Find"));
        setFixedHeight(sizeHint().height());
        

        }

        void findtest::findClicked()
        {QString text = lineEdit->text();

        Qt::CaseSensitivity cs =
        caseCheckBox->isChecked() ? Qt::CaseSensitive
        :Qt::CaseInsensitive;
        if(backwardCheckBox ->isChecked()){
        emit findPrevious(text,cs);
        }else{

        emit findNext(text, cs);
        

        }
        }
        void findtest::enableFindButton(const QString &text)
        {
        findButton->setEnabled(!text.isEmpty());

        }

        #include "findtest.h"
        #include <QApplication>

        int main(int argc, char *argv[])
        {
        QApplication a(argc, argv);
        findtest *dialog = new findtest;
        dialog->show();
        return a.exec();
        }
        @
        error: C2061: syntax error : identifier 'CaseSensitive'

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TioRoy
          wrote on last edited by
          #4

          Esqueci que só o .h não compila. :)

          Você está usando o Qt::CaseSentive, que é o valor do enum

          @ enum CaseSensitivity {
          CaseInsensitive,
          CaseSensitive
          };
          @

          No seu código, o correto é:

          @
          signals:

          void findNext(const QString &str, Qt::CaseSensitivity cs);
          void findPrevious(const QString &str ,Qt::CaseSensitivity cs);
          

          @

          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