问题一:
我写了一段代码但是最后的效果不是我想要的,还请高人帮忙指点一下,谢谢啦!
void ClientInfoBase::openfile1()
{
QString newfilename1 = QFileDialog::getOpenFileName( "",
tr("Jpg File(*.jpg);;Bmp File(*.bmp);;Png File(*.png)"),
this,
"open files dialog"
"Select one file to open" );
if ( !newfilename1.isEmpty() ) {
textLabel1->setPixmap(newfilename1);
scrollArea->addChild(textLabel1);
scrollArea->setHScrollBarMode(QScrollView::ScrollBarMode::AlwaysOn);
scrollArea->setVScrollBarMode(QScrollView::ScrollBarMode::AlwaysOn);
scrollArea->show();
}
}
所要显示的图片没有在原来的窗口上显示,而是新打开了一个窗口,在新打开的窗口上显示了。怎样才能在原来的窗口上显示呢?还请高人指点,谢谢!
问题二:
void ClientInfoBase::openfile1()
{
QString newfilename1 = QFileDialog::getOpenFileName( "",
tr("Jpg File(*.jpg);;Bmp File(*.bmp);;Png File(*.png)"),
this,
"open files dialog"
"Select one file to open" );
if ( !newfilename1.isEmpty() ) {
QScrollView* scrollArea = new QScrollView(this);
textLabel1= new QLabel( scrollArea->viewport());
textLabel1->setPixmap(newfilename1);
scrollArea->addChild(textLabel1);
scrollArea->setHScrollBarMode(QScrollView::ScrollBarMode::AlwaysOn);
scrollArea->setVScrollBarMode(QScrollView::ScrollBarMode::AlwaysOn);
scrollArea->show();
}
}
显示的画面出现在原窗口的左上角,怎样才能使图片出现在原窗口的中间,或者是想要显示的位置呢?请高手指点!谢谢!