当前位置: 首页>>代码示例>>C++>>正文


C++ QTextBrowser::setMinimumSize方法代码示例

本文整理汇总了C++中QTextBrowser::setMinimumSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QTextBrowser::setMinimumSize方法的具体用法?C++ QTextBrowser::setMinimumSize怎么用?C++ QTextBrowser::setMinimumSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTextBrowser的用法示例。


在下文中一共展示了QTextBrowser::setMinimumSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QDialog

/*!
    Constructs a new about box on top of given \a parent window.
*/
AboutBox::AboutBox(QWidget * parent) : QDialog(parent)
{
    setWindowTitle("About MaxCalc");

    tstring labelText = _T("MaxCalc v");
    labelText += Constants::VERSION;
    labelText += _T(" (");
    labelText += _T("built: ");
    tstring date = stringToWideString(__DATE__);
    labelText += date;
    labelText += _T(")<br>");
    labelText += Constants::COPYRIGHT;
    labelText += _T("<br><a href='");
    labelText += Constants::WEBSITE;
    labelText += _T("'>");
    labelText += Constants::WEBSITE;
    labelText += _T("</a>");

    QTextBrowser * label = new QTextBrowser;
    label->setHtml(QString::fromWCharArray(labelText.c_str()));
    label->setOpenExternalLinks(true);
    label->setFrameStyle(QFrame::NoFrame);
    QPalette p;
    p.setColor(QPalette::Base, p.color(QPalette::Background));
    label->setPalette(p);
    label->setLineWrapMode(QTextEdit::NoWrap);
    label->document()->adjustSize();
    label->setMinimumSize(label->document()->size().toSize());
    label->setMaximumSize(label->document()->size().toSize());

    QPushButton * closeButton = new QPushButton;
    closeButton->setText(tr("&Close"));

    QGridLayout * layout = new QGridLayout;
    layout->addWidget(label, 1, 0, 1, -1);
    layout->addItem(new QSpacerItem(20, 10, QSizePolicy::Minimum,
        QSizePolicy::Fixed), 2, 1, 1, 1);
    layout->addItem(new QSpacerItem(20, 20,
        QSizePolicy::Expanding), 3, 0, 1, 1);
    layout->addWidget(closeButton, 3, 1, 1, 1);
    layout->addItem(new QSpacerItem(20, 20,
        QSizePolicy::Expanding), 3, 2, 1, 1);    

    setLayout(layout);

    setMaximumSize(sizeHint());
    setMinimumSize(sizeHint());

    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
}
开发者ID:Mishamax,项目名称:maxcalc,代码行数:53,代码来源:aboutbox.cpp

示例2: file

DialogAbout::DialogAbout(PageWelcome* parent)
	: QDialog(parent) {

	setWindowTitle(tr("About SimpleScreenRecorder"));

	QString html_about;
	{
		QFile file(":/about.htm");
		if(file.open(QIODevice::ReadOnly | QIODevice::Text))
			html_about = file.readAll();
	}

	html_about.replace("%MOREINFO%", tr("For more information:"));
	html_about.replace("%SOURCECODE%", tr("The source code of this program can be found at:"));
	html_about.replace("%USES%", tr("This program uses:"));
	html_about.replace("%USES_QT4%", tr("%1 for the graphical user interface").arg("<a href=\"https://qt-project.org/\">Qt 4</a>"));
	html_about.replace("%USES_LIBAV_FFMPEG%", tr("%1 or %2 (depending on your distribution) for video/audio encoding").arg("<a href=\"http://libav.org/\">libav</a>").arg("<a href=\"http://ffmpeg.org/\">ffmpeg</a>"));
	html_about.replace("%USES_ELFHACKS%", tr("%1 for hooking system functions for OpenGL recording").arg("<a href=\"https://github.com/nullkey/elfhacks\">elfhacks</a>"));
	html_about.replace("%VERSION%", PACKAGE_VERSION);
	html_about.replace("%VERSIONINFO%", GetVersionInfo().replace("\n", "<br>\n"));

	QTextBrowser *textbrowser = new QTextBrowser(this);
	textbrowser->setHtml(html_about);
	textbrowser->setOpenExternalLinks(true);
	textbrowser->setMinimumSize(700, 500);

	QPushButton *pushbutton_close = new QPushButton("Close", this);

	connect(pushbutton_close, SIGNAL(clicked()), this, SLOT(accept()));

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->addWidget(textbrowser);
	{
		QHBoxLayout *layout2 = new QHBoxLayout();
		layout->addLayout(layout2);
		layout2->addStretch();
		layout2->addWidget(pushbutton_close);
		layout2->addStretch();
	}

}
开发者ID:NikTh,项目名称:ssr,代码行数:41,代码来源:PageWelcome.cpp

示例3: file

DialogAbout::DialogAbout(PageWelcome* parent)
	: QDialog(parent) {

	setWindowTitle("About SimpleScreenRecorder");

	QString html_about;
	{
		QFile file(":/about.htm");
		if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
			html_about = "Error: Can't load about dialog text.";
		} else {
			html_about = file.readAll();
		}
	}

	html_about.replace("%VERSION%", SSR_VERSION);
	html_about.replace("%VERSIONINFO%", GetVersionInfo().replace("\n", "<br>\n"));

	QTextBrowser *textbrowser = new QTextBrowser(this);
	textbrowser->setHtml(html_about);
	textbrowser->setOpenExternalLinks(true);
	textbrowser->setMinimumSize(700, 500);

	QPushButton *pushbutton_close = new QPushButton("Close", this);

	connect(pushbutton_close, SIGNAL(clicked()), this, SLOT(accept()));

	QVBoxLayout *layout = new QVBoxLayout(this);
	layout->addWidget(textbrowser);
	{
		QHBoxLayout *layout2 = new QHBoxLayout();
		layout->addLayout(layout2);
		layout2->addStretch();
		layout2->addWidget(pushbutton_close);
		layout2->addStretch();
	}

}
开发者ID:Half-Shot,项目名称:ssr,代码行数:38,代码来源:PageWelcome.cpp

示例4: main

int main(int argc, char** argv)
{
  KAboutData about("DialogTest", 0, ki18n("DialogTest"), "version");
  KCmdLineArgs::init(argc, argv, &about);

  KApplication app;

  // -----
  QString text= // the explanation shown by the example dialog
    "<center><h1>KDialog Example</h1></center><hr><br>"
    "This example shows the usage of the <i>KDialog</i>  class. "
    "<i>KDialog</i> is the KDE user interface class used to create "
    "dialogs with simple layout without having to define an own dialog "
    "style for your application. <br>"
    "It provides some standards buttons that are needed in most dialogs. Each one may be "
    "hidden, enabled or disabled, and tooltips and quickhelp texts might be"
    " added. And you do not need to bother about geometry management, this "
    "is all done automatically.<br>"
    "The class supports the creation of dialogs without being forced "
    "to derive an own class for it, but you may derive your own class "
    "for a better code structure.<br>"
    "If you wrote a help chapter explaining what your dialog does, you "
    "should add a link to it to the dialog using <tt>setHelp</tt>. You do "
    "not have to take care about launching the help viewer, just set the "
    "help file and topic and of course copy it to your documentation "
    "directory during the program installation.";
  /* Create the dialog object. DialogBase is derived from QDialog, but
     you do not need to derive it to create a nice-looking dialog. Mostly,
     you already have a widget class representing the core of your dialog,
     and you only need to add a frame around it and the default buttons.

     If you want to derive it, you still can, moving all code shown here
     inside of your new class. */
  KDialog dialog;
  dialog.setButtons( KDialog::Ok | KDialog::Cancel | KDialog::Details | KDialog::User1 | KDialog::Help );
  dialog.setButtonGuiItem( KDialog::User1 , KGuiItem("Test") );
  dialog.setCaption("dialog!");
  /* Set a help chapter. If you do not set one, the link is not shown, and the
     upper part of the frame shrinks as much as possible. The help window "
     "will of course only pop up if you correctly installed kdebase. */
  // I disabled it, as khcclient did not run for me.
   dialog.setHelp("kdehelp/intro.html", "");
  /* This QTextView is intended to be the main widget of our dialog. The
     main widget is placed inside the dialogs frame, with the buttons below
     it. You do not have to take care about the size handling, but it is a
     good idea to set the main wigdets minimum size, since the sizes Qt and
     the DialogBase class guess are sometimes ugly.

     It is important that your main widget is created with the dialog object
     as its parent! */
  QTextBrowser view;
  view.setHtml( text );
  dialog.setMainWidget( &view );

  QLabel label("this is a place for some advanced settings" ,&dialog);
  dialog.setDetailsWidget( &label);
	
  //view.setMinimumSize(400, view.heightForWidth(400)+20);
  view.setMinimumSize( 250, 300 );
  /* After finishing the setup of your main widget, the dialog needs to be
     adjusted. It is not done automatically, since the layout of the main
     widget may change before the dialog is shown. Additionally, setting a
     help chapter may cause a need for adjustment since it modifies the height
     of the upper frame. */
 // dialog.resize(dialog.minimumSize());
  /* The dialog object is used just as any other QDialog: */
  if(dialog.exec())
    {
      qDebug("Accepted.");
    } else {
      qDebug("Rejected.");
    }
  return 0;
}
开发者ID:fluxer,项目名称:kdelibs,代码行数:74,代码来源:kdialogtest.cpp


注:本文中的QTextBrowser::setMinimumSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。