void View::addArticle(const Article &article) { Button *btn = new Button(article.draw(QRect(0, 0, 700 / 3, 700 / 3))); connect(btn, SIGNAL(pressed()), this, SLOT(articleClicked())); btn->resize(700 / 3, 700 / 3); btn->setPos((_cptArticles % 3) * (700 / 3), (_cptArticles / 3) * (700 / 3) + 30); scene()->addItem(btn); ++_cptArticles; }
void View::addArticle(const Article &article) { unsigned int w = size().width() / 3; unsigned int h = (size().height() - _topBar->size().height()) / 3; Button *btn = new Button(article.draw(QRect(0, 0, w, h))); connect(btn, SIGNAL(pressed()), this, SLOT(articleClicked())); btn->resize(w, h); btn->setPos((_cptArticles % 3) * (w), (_cptArticles / 3) * h + _topBar->size().height()); scene()->addItem(btn); ++_cptArticles; }