Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. horizontalScrollBar() Error
Forum Updated to NodeBB v4.3 + New Features

horizontalScrollBar() Error

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 201 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1
    QTScrollArea::QTScrollArea(QWidget *parent)
    {
    	ui.setupUi(this);
    
    	//m_pTimer = new QTimer(this);
    	//connect(m_pTimer, SIGNAL(timeout()), this, SLOT(UpdateTick()));
    	//m_pTimer->start(500);
    	
    	// 사이즈 (400, 250)
    	this->ui.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    	this->ui.scrollArea->grabGesture(Qt::TapGesture);
    
    	m_pWidget = new QWidget(this->ui.scrollArea);
    	this->ui.scrollArea->setWidget(m_pWidget);
    
    	QHBoxLayout* layout = new QHBoxLayout();
    	m_pWidget->setLayout(layout);
    	layout->setContentsMargins(QMargins(0, 0, 0, 0));
    	layout->setSpacing(0);
    
    	for (int i = 0; i < 30; i++)
    	{
    		QPushButton* pbtn = new QPushButton(QString("%1").arg(i));
    		pbtn->setFixedSize(400 / 6, 200);
    
    		layout->addWidget(pbtn);
    	}
    
    	this->connect(this->ui.pushButton, &QPushButton::clicked, this, &QTScrollArea::BtnPrev);
    	this->connect(this->ui.pushButton_2, &QPushButton::clicked, this, &QTScrollArea::BtnNext);
    
    	this->ui.scrollArea->horizontalScrollBar()->setValue(1);   // C2027 Error
    }
    

    An error has occurred.
    Isn't horizontalScrollBar also created when creating scrollArea objects? Why does it say that you used an undefined format?

    eyllanescE 1 Reply Last reply
    0
    • I IknowQT
      QTScrollArea::QTScrollArea(QWidget *parent)
      {
      	ui.setupUi(this);
      
      	//m_pTimer = new QTimer(this);
      	//connect(m_pTimer, SIGNAL(timeout()), this, SLOT(UpdateTick()));
      	//m_pTimer->start(500);
      	
      	// 사이즈 (400, 250)
      	this->ui.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
      	this->ui.scrollArea->grabGesture(Qt::TapGesture);
      
      	m_pWidget = new QWidget(this->ui.scrollArea);
      	this->ui.scrollArea->setWidget(m_pWidget);
      
      	QHBoxLayout* layout = new QHBoxLayout();
      	m_pWidget->setLayout(layout);
      	layout->setContentsMargins(QMargins(0, 0, 0, 0));
      	layout->setSpacing(0);
      
      	for (int i = 0; i < 30; i++)
      	{
      		QPushButton* pbtn = new QPushButton(QString("%1").arg(i));
      		pbtn->setFixedSize(400 / 6, 200);
      
      		layout->addWidget(pbtn);
      	}
      
      	this->connect(this->ui.pushButton, &QPushButton::clicked, this, &QTScrollArea::BtnPrev);
      	this->connect(this->ui.pushButton_2, &QPushButton::clicked, this, &QTScrollArea::BtnNext);
      
      	this->ui.scrollArea->horizontalScrollBar()->setValue(1);   // C2027 Error
      }
      

      An error has occurred.
      Isn't horizontalScrollBar also created when creating scrollArea objects? Why does it say that you used an undefined format?

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @IknowQT add #include <QScrollBar>

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      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