本文整理汇总了C++中QScrollArea::setLayout方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::setLayout方法的具体用法?C++ QScrollArea::setLayout怎么用?C++ QScrollArea::setLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::setLayout方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupUserInterface
void moviemanager::setupUserInterface()
{
mainWindow = new QWidget(this);
mainHLayout = new QHBoxLayout(mainWindow);
firstVLayout = new QVBoxLayout(mainWindow);
secondVLayout = new QVBoxLayout(mainWindow);
thirdVLayout = new QVBoxLayout(mainWindow);
mainHLayout->addItem(firstVLayout);
mainHLayout->addItem(secondVLayout);
mainHLayout->addItem(thirdVLayout);
//add layouting information here
//adding widgets into the firstVLayout
//adding searchbar
QHBoxLayout* searchHLayout = new QHBoxLayout(mainWindow);
firstVLayout->addItem(searchHLayout);
searchHLayout->addWidget(new QLabel("Search:", mainWindow));
searchBar = new KLineEdit("", mainWindow);
searchHLayout->addWidget(searchBar);
searchHLayout->setAlignment(Qt::AlignTop); //searchbar alignment
//connecting searchbar return pressed to a slot
if(connect(searchBar,
SIGNAL(returnPressed(QString)),
this,
SLOT(slotSearchBarReturnPressed(QString))) == false)
{
qDebug() << "searchBar connect is not successful";
}
//adding klistwidget for displaying movies
mainMovieList = new KListWidget(mainWindow);
mainMovieList->setSortingEnabled(true);
fetchAllMovieList(mainMovieList);
firstVLayout->addWidget(mainMovieList);
//connecting the mainMovieList signal to a slot
if(connect(mainMovieList,
SIGNAL(activated(QModelIndex)),
this,
SLOT(slotMovieClicked(QModelIndex))) == false)
{
qDebug() << "mainMovieList connect is not successful";
}
//adding widgets into secondVLayout
secondVLayout->addWidget(new QLabel("<span style='font-size: 20px;'>Movie Details</span>", mainWindow));
QScrollArea * scrollArea = new QScrollArea(mainWindow);
//scrollArea->setLayout();
//scrollArea->setAlignment(Qt::AlignBottom);
secondVLayout->addWidget(scrollArea);
scrollArea->setWidgetResizable(false);
//scrollArea->setVerticalScrollBar(new QScrollBar());
middleInnerWidget = new QWidget(mainWindow);
//middleInnerWidget->setMaximumHeight(50);
scrollArea->setWidget(middleInnerWidget);
//secondVLayout->addWidget(middleInnerWidget);
middleInnerVLayout = new QVBoxLayout(middleInnerWidget);
scrollArea->setLayout(middleInnerVLayout);
QLabel* tempTitle = new QLabel("<span style='font-size: 20px;'>Title</span>", middleInnerWidget);
tempTitle->setAlignment(Qt::AlignTop);
middleInnerVLayout->addWidget(tempTitle);
artwork = new QWebView(middleInnerWidget);
artwork->load(QUrl("file:///home/sandeep/.moviemanager/tt0000000.jpg"));
artwork->setMinimumSize(320,474);
artwork->setMaximumSize(320,474);
middleInnerVLayout->addWidget(artwork);
//adding widgets into thirdVLayout
thirdVLayout->addWidget(new QLabel("<span style='font-size: 20px;'>Recommended Movies</span>", mainWindow));
recoMovieList = new KListWidget(mainWindow);
recoMovieList->setSortingEnabled(true);
fetchRecoMovieList(recoMovieList);
thirdVLayout->addWidget(recoMovieList);
//connecting the mainMovieList signal to a slot
if(connect(recoMovieList,
SIGNAL(activated(QModelIndex)),
this,
SLOT(slotMovieClicked(QModelIndex))) == false)
{
qDebug() << "recoMovieList connect is not successful";
}
setCentralWidget(mainWindow);
}
示例2: showEditHistory
void LogDetailWidget::showEditHistory()
{
QModelIndex index = ui.aaView->currentIndex();
if(index.row() <0) return;
QAbstractItemModel* model = ui.aaView->model();
QString timestamp = model->data(model->index(index.row(), 0), Qt::DisplayRole).toString();
QString compName = model->data(model->index(index.row(), 2), Qt::DisplayRole).toString();
QString type = model->data(model->index(index.row(), 4), Qt::DisplayRole).toString();
QString value = model->data(model->index(index.row(), 5), Qt::DisplayRole).toString();
QWidget *histWidget = new QWidget;
histWidget->resize(QSize(800,600));
QVBoxLayout *boxlayout = new QVBoxLayout;
QScrollArea* area = new QScrollArea;
QGridLayout *gridLayout = new QGridLayout;
QLabel* fileLabel = new QLabel;
fileLabel->setText("Source Code File: " + compName);
gridLayout->addWidget(fileLabel, 0, 0, 1, -1);
histWidget->setLayout(boxlayout);
boxlayout->addWidget(area);
area->setLayout(gridLayout);
LogEvent pre_e;
bool isFirst = true;
int row = 1;
for(int i=0; i<logMan.events.size(); i++)
{
LogEvent e = logMan.events[i];
if(!e.isHasAcc) continue;
if(e.acc.parent_name == compName.toStdString() && e.acc.type == type.toStdString())
{
if(isFirst)
{
QLabel* timeLabel = new QLabel;
timeLabel->setText(QString::fromStdString(e.timestamp));
QLabel* edit = new QLabel;
edit->setText("First Time Open");
gridLayout->addWidget(timeLabel, row, 0, 1, 1);
gridLayout->addWidget(edit, row, 1, 1, 1);
isFirst = false;
}
else
{
QLabel* timeLabel = new QLabel;
timeLabel->setText(QString::fromStdString(e.timestamp));
gridLayout->addWidget(timeLabel, row, 0, 1, 1);
string s1 = pre_e.acc.value;
replaceAll(s1, "\\n", "\n");
replaceAll(s1, "\\t", "\t");
string s2 = e.acc.value;
replaceAll(s2, "\\n", "\n");
replaceAll(s2, "\\t", "\t");
QString str1 = QString::fromStdString(s1);
QString str2 = QString::fromStdString(s2);
diff_match_patch dmp;
QList<Diff> res = dmp.diff_main(str1,str2, true);
dmp.diff_cleanupSemantic(res);
if(res.size() == 1 && res[0].operation == Operation::EQUAL)
{
QLabel* edit = new QLabel;
edit->setText("No Difference");
gridLayout->addWidget(edit, row, 1, 1, 1);
}
else
{
QTextEdit* edit = new QTextEdit;
edit->setText(dmp.diff_toString(res));
gridLayout->addWidget(edit, row, 1, 1, 1);
}
}
pre_e = e;
row++;
}
}
histWidget->show();
}
示例3: QMainWindow
TextEdit::TextEdit(QWidget *parent)
: QMainWindow(parent)
{
setToolButtonStyle(Qt::ToolButtonFollowStyle);
setupFileActions();
setupEditActions();
setupTextActions();
{
// QMenu *helpMenu = new QMenu(tr("Help"), this);
// menuBar()->addMenu(helpMenu);
// helpMenu->addAction(tr("About"), this, SLOT(about()));
// helpMenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
}
textEdit = new QTextEdit(this);
//////////////////////////////////////////////////
connect(textEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)),
this, SLOT(currentCharFormatChanged(QTextCharFormat)));
connect(textEdit, SIGNAL(cursorPositionChanged()),
this, SLOT(cursorPositionChanged()));
///////////
//setCentralWidget(textEdit);
//blank=new Blank(this);
//setCentralWidget(blank);
//create a transparent canvas and put it on the top of textEdit
image =new MyCanvas(900,800,this);
textEdit->setFixedSize(QSize(800,800));
textEdit->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark
image->setFixedSize(QSize(800,800));
image->setStyleSheet(QString::fromUtf8("border:1px solid #000000;"));
QScrollArea* scrollArea = new QScrollArea;
scrollArea->setFixedSize(QSize(1800,900));
//scrollArea->setWidget(image); //将画布添加到scrollArea中
scrollArea->setBackgroundRole(QPalette::Light); //scrollArea对象的背景色设为Dark
//scrollArea->setBackgroundColor(QColor::white);
// QStackedLayout *stackedLayout = new QStackedLayout;
// stackedLayout->addWidget(image);
// stackedLayout->addWidget(textEdit);
// stackedLayout->setStackingMode(QStackedLayout::StackAll);
QHBoxLayout* hLayout=new QHBoxLayout();
hLayout->addWidget(textEdit);
hLayout->addWidget(image);
// scrollArea->setLayout(stackedLayout);
scrollArea->setLayout(hLayout);
//scrollArea->setGeometry(QRect(50,50,800,800));
setCentralWidget(scrollArea); //将scrollArea加入到主窗口的中心区new QPainter(this);
scrollArea->setAlignment(Qt::AlignHCenter);
//after canvas handle the mouse-drag event, emit it to the edittext for farther handling
connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),this,SLOT(onMouseMove(QMouseEvent*)));
//connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(mouseMoveEvent(QMouseEvent*)));
//connect(image,SIGNAL(mouseMoveSig(QMouseEvent*)),textEdit,SLOT(cursorPositionChanged(QMouseEvent*)));
//connect(this,SIGNAL(mouseMoveSig(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
//connect(textEdit,SIGNAL(mouseMoveEvent(QMouseEvent*)),image,SLOT(mouseMoveSlot(QMouseEvent*)));
// textEdit->setFocus();
setCurrentFileName(QString());
fontChanged(textEdit->font());
colorChanged(textEdit->textColor());
alignmentChanged(textEdit->alignment());
connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
actionSave, SLOT(setEnabled(bool)));
connect(textEdit->document(), SIGNAL(modificationChanged(bool)),
this, SLOT(setWindowModified(bool)));
connect(textEdit->document(), SIGNAL(undoAvailable(bool)),
actionUndo, SLOT(setEnabled(bool)));
connect(textEdit->document(), SIGNAL(redoAvailable(bool)),
actionRedo, SLOT(setEnabled(bool)));
setWindowModified(textEdit->document()->isModified());
actionSave->setEnabled(textEdit->document()->isModified());
actionUndo->setEnabled(textEdit->document()->isUndoAvailable());
actionRedo->setEnabled(textEdit->document()->isRedoAvailable());
connect(actionUndo, SIGNAL(triggered()), textEdit, SLOT(undo()));
connect(actionRedo, SIGNAL(triggered()), textEdit, SLOT(redo()));
actionCut->setEnabled(false);
actionCopy->setEnabled(false);
connect(actionCut, SIGNAL(triggered()), textEdit, SLOT(cut()));
connect(actionCopy, SIGNAL(triggered()), textEdit, SLOT(copy()));
connect(actionPaste, SIGNAL(triggered()), textEdit, SLOT(paste()));
connect(textEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
connect(textEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
#ifndef QT_NO_CLIPBOARD
connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardDataChanged()));
//.........这里部分代码省略.........