c++ - 此警告消息是什么意思?

标签 c++ qt

Product.cpp:34: warning: the address of ‘QTextStream& endl(QTextStream&)’, will always evaluate as ‘true’

Product.cpp: In member function ‘void Product::setProductToSold()’:

Product.cpp:45: warning: the address of ‘QTextStream& endl(QTextStream&)’, will always evaluate as ‘true’

#include <string>
#include <iostream>
#include <time.h>
using std::string;
using std::cout;

#include "Product.h"

Product::Product()
{
    seller = "";
    itemName = "";
    price = 0.00;
    min = 0.00;
    buyingPrice = 0.00;
    time = 0;
    description = "";
    highestBidder = "None";
    currentBid = 0.00;
    
    timer = new QTimer( this );
    connect( timer, SIGNAL(timeout()), this, SLOT(setProductToSold()) );
}

void Product::startTimer()
{
Line 34:    cout << " Timer Started " << endl;
    timer->start( 2000, TRUE ); // 2 seconds single-shot timer
}

void Product::setHandler(Handler *h)
{
    handler = h;
}

void Product::setProductToSold()
{
Line 45:    cout << " Item auction over" << endl;
}

我的产品.h::

#include <string>

#include <qobject.h>
#include <qtimer.h>
#include <qgl.h>

#include "HandleTCPClient.h"

class Handler;

//Define ourselves a product class
class Product : public QObject
    {
    
        Q_OBJECT
    
    
    public:
        Product();
        
        QTimer *timer;
        string seller, itemName, description, highestBidder;
        double price, min, buyingPrice, currentBid;
        int time;
        bool isSold;
        Handler *handler;
        
        void setHandler(Handler *h);
        void startTimer();
        
    public slots:
        void setProductToSold();
        
    };
    
#endif

谢谢:)

最佳答案

您(或 Qt)正在重新定义 endl 吗?尝试把 std::endl

关于c++ - 此警告消息是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1792521/

相关文章:

c++ - 如何使用 C++ 使用字符串打印变量

c++ getline没有得到输入

c++ - QT 自定义 TreeView

c++ - 将 TextStyle 从 C++ 传递到 QML

c++ - 上传 .csv 或 .txt 文件以填充 QTableView

c++ - C++ 中的抽象类(接口(interface))数组

c++ - Windows 下的异常处理和堆栈跟踪(MinGW/gcc)

c++ - 为什么 `std::exit` 没有按预期触发析构函数?

c++ - QT 创建许多复杂的小部件

python - 没有为 QML ComboBox 定义 modelData,并且在 QAbstractListModel 中具有多个角色