我希望能够在我的脚本中接受强制和可选标志.这是我到目前为止所拥有的.
#!bin/bash
while getopts ":a:b:cdef" opt; do
case $opt in
a ) APPLE="$OPTARG";;
b ) BANANA="$OPTARG";;
c ) CHERRY="$OPTARG";;
d ) DFRUIT="$OPTARG";;
e ) EGGPLANT="$OPTARG";;
f ) FIG="$OPTARG";;
\?) echo "Invalid option: -"$OPTARG"" >&2
exit 1;;
: ) echo "Option -"$OPTARG" requires an argument." >&2
exit 1;;
esac
done
echo "Apple is "$APPLE""
echo "Banana is "$BANANA""
echo "Cherry is "$CHERRY""
echo "Dfruit is "$DFRUIT""
echo "Eggplant is "$EGGPLANT""
echo "Fig is "$FIG""
Run Code Online (Sandbox Code Playgroud)
但是,输出如下:
bash script.sh -a apple -b banana …Run Code Online (Sandbox Code Playgroud) For the life of me, I cannot find the setting that allows changes to Smart Highlighting in Qt Creator. See the image below for an example. When I click the start variable, Qt Creator puts a box around other occurrences of the variable. Where is the setting to change the background color of these highlights?
Thanks in advance.
我有一个有3个主要小部件的应用程序.我也有一个弹出窗口QDockWidget.我正试图QDockWidget将底部停靠在底部小部件的右半部分,但正如您在下图中看到的那样,我可以停靠窗口的唯一位置是应用程序的边缘.我怎样才能使QDockWidget窗口占据底部小部件的右半部分?
此外,有没有办法QDockWidget在打开应用程序时已经停靠,而不是让它在自己的窗口中单独打开?
编辑:在下面使用@ Bertrand的答案,这是我最后做的事情:
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
void on_actionRestore_layout_triggered();
QMainWindow* m_rightSideWindow;
QDockWidget* m_dockWidget1;
QDockWidget* m_dockWidget2;
QDockWidget* m_dockWidget3;
};
#endif // MAINWINDOW_H
Run Code Online (Sandbox Code Playgroud)
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtWidgets>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
m_rightSideWindow(NULL),
m_dockWidget1(NULL),
m_dockWidget2(NULL),
m_dockWidget3(NULL)
{
ui->setupUi(this);
QSplitter *splitter = new …Run Code Online (Sandbox Code Playgroud) 我想设置一个QTimer在我的程序中运行的函数。我有以下代码:
// Redirect Console output to a QTextEdit widget
new Q_DebugStream(std::cout, ui->TXT_C);
// Run a class member function that outputs Items via cout and shows them in a QTextEdit widget
// I want to set up a QTimer like the animation below for this.
myClass p1;
p1.display("Item1\nItem2\nItem3", 200);
// show fading animation of a QTextEdit box after 1000 milliseconds
// this works and will occur AFTER the QDialog shows up no problem.
QGraphicsOpacityEffect *eff = new QGraphicsOpacityEffect(this);
ui->TXT_C->setGraphicsEffect(eff); …Run Code Online (Sandbox Code Playgroud)