Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QTextstream problems
QtWS25 Last Chance

QTextstream problems

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.0k Views
  • 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.
  • S Offline
    S Offline
    spode
    wrote on last edited by
    #1

    @
    #include "biglietto.h"
    #include "gestore.h"
    #include <QMessageBox>

    Biglietto::Biglietto(QString parolaDaTradurre, QString traduzioneDellaParola)
    {
    importante = false;
    parola = parolaDaTradurre;
    traduzione = traduzioneDellaParola;
    sfondoBiglietto = Qt::green;
    }

    Biglietto::Biglietto(bool importanzaDellaParola, QString parolaDaTradurre, QString traduzioneDellaParola, QColor sfondoDelBiglietto)
    {
    importante = importanzaDellaParola;
    parola = parolaDaTradurre;
    traduzione = traduzioneDellaParola;
    sfondoBiglietto = sfondoDelBiglietto;
    }

    bool Biglietto::salvaBiglietto(Biglietto biglietto_daSalvare)
    {
    if(file_contenente_elencoParole->open(QIODevice::Text | QIODevice::ReadWrite | QIODevice::Append))
    {
    QTextStream scrivi_leggi(file_contenente_elencoParole);
    //se la parola non esiste già
    if(scrivi_leggi.readAll().contains(biglietto_daSalvare.traduzione, Qt::CaseInsensitive))
    {
    QMessageBox info;
    info.setWindowTitle("Parola gia' esistente");
    info.setText("La parola in questione e' gia' registrata!");
    info.exec();
    }
    else
    {
    scrivi_leggi << "PA " << parola << " TR " << traduzione << " CO " << sfondoBiglietto << " IM " << importante;

    }
    else
    {
        QMessageBox info;
        info.setWindowTitle("File con le parole registrate non apribile");
        info.setText("Cartella o device protetta?");
        info.exec&#40;&#41;;
    }
    

    }

    //formato biglietto:
    /*
    PA parola TR traduzione CO colore IM bool\n
    */
    @

    problems are: C:\Users\7-Spode\Documents\Progetti\QT\mobile\WoerterErinnerung-build-simulator..\WoerterErinnerung\biglietto.cpp:36: error: no match for 'operator<<' in '((QTextStream*)((QTextStream*)((QTextStream*)((QTextStream*)scrivi_leggi.QTextStream::operator<<(((const char*)"PA ")))->QTextStream::operator<<(((const QString&)((const QString*)(&((Biglietto*)this)->Biglietto::parola)))))->QTextStream::operator<<(((const char*)" TR ")))->QTextStream::operator<<(((const QString&)((const QString*)(&((Biglietto*)this)->Biglietto::traduzione)))))->QTextStream::operator<<(((const char*)" CO ")) << ((Biglietto*)this)->Biglietto::sfondoBiglietto'

    scrivi_leggi << "PA " << parola << " TR " << traduzione << " CO " << sfondoBiglietto << " IM " << importante;
    note that: scrivi_leggi is QTextStream, traduzione and parola are QString, importante is bool and sfondoBiglietto is QColor(from Qt::green, for example). how to trasform a QColor in QString?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      loladiro
      wrote on last edited by
      #2

      You'll have to either have a mapper function mapping the color to it's name or generate a string based on it's value (e.g. in a html-like format).

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goetz
        wrote on last edited by
        #3

        You can use "QColor::name() ":http://doc.qt.nokia.com/4.7/qcolor.html#name to convert the color to a QString representing the #rrggbb RGB value and use "QColor::setNamedColor() ":http://doc.qt.nokia.com/4.7/qcolor.html#setNamedColor to convert the QString back to a QColor. The QString can be written and read with a QTextStream.

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • S Offline
          S Offline
          spode
          wrote on last edited by
          #4

          thank you a lot! =)

          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