我正在使用 Visual Studio 2019。
我想为 Visual Studio 创建一个设置文件,其中包含我自己的格式规则,任何人都可以为其 Visual Studio 导入这些设置。(我认为这对于新手来说是一种更简单的方法,而不是指导他安装格式代码扩展)。我将这个文件命名为MyFormattingRules.vssettings. 我对这个文件扩展名的看法正确吗?
如何使用我自己的规则设置此文件中的格式规则?
我找到了这个链接,但它并没有真正达到我想要的效果。 https://learn.microsoft.com/vi-vn/visualstudio/ide/cpp-editorconfig-properties?view=vs-2019
例如:
示例1.h
void myFunc(int param);
void myFunc2(
int param1,
int param2,
int param3);
Run Code Online (Sandbox Code Playgroud)
示例2.h
class Myclass
{
public:
MyClass();
private:
int myVar;
}
Run Code Online (Sandbox Code Playgroud)
保存后,myVar应该变成m_myVar. 是否可以使用设置文件执行此类操作?如果没有,您能推荐一个可以做到这一点的工具吗?
你能给我一个这样的文件的例子吗?
c++ formatting code-formatting visual-studio visual-studio-2019
我有一个奇怪的表调用mytable,没有列是主要的.
Name | Company | Position
Michael Google Tester
Michael Google Tester
Michael Google Tester
Peter Facebook Developer
Peter Facebook Developer
Peter Facebook Developer
Peter Facebook Developer
Run Code Online (Sandbox Code Playgroud)
我想要的是
Name | Company | Position
Michael Google Tester
Peter Facebook Developer
Run Code Online (Sandbox Code Playgroud)
通过一些解决方案,我在这里找到了同样的问题,但它们没有用.例如:
DELETE FROM mytable WHERE Name NOT IN (SELECT MAX(Name) FROM mytable GROUP BY Company);
我应该在这个表中编辑,使用SQLite,没有新表创建,也没有CTE.我该怎么做?
我需要创建一个像这样的登录对话框
图像文件:eyeOn.png,eyeOff.png
要求:
我刚刚构建了布局。
QGridLayout *mainlogin = new QGridLayout();
QLabel *usernameLabel = new QLabel;
usernameLabel->setWordWrap(true);
usernameLabel->setText("Username");
mainlogin->addWidget(usernameLabel, 0, 0);
QComboBox *usernameLineEdit = new QComboBox;
usernameLineEdit->setEditable(true);
usernameLabel->setBuddy(usernameLineEdit);
mainlogin->addWidget(usernameLineEdit, 0, 1);
QLabel *capslockShow = new QLabel;
capslockShow->setWordWrap(true);
capslockShow->setText(" ");
mainlogin->addWidget(capslockShow, 1, 1);
QLabel *passwordLabel = new QLabel;
passwordLabel->setWordWrap(true);
passwordLabel->setText("Password");
mainlogin->addWidget(passwordLabel, 2, 0);
QLineEdit *passwordLineEdit = new QLineEdit;
passwordLineEdit->setEchoMode(QLineEdit::Password);
QAction *myAction = passwordLineEdit->addAction(QIcon(":/eyeOff.png"), QLineEdit::TrailingPosition);
passwordLabel->setBuddy(passwordLineEdit);
mainlogin->addWidget(passwordLineEdit, 2, 1);
Run Code Online (Sandbox Code Playgroud)
接下来我应该做什么?请帮我提供代码片段。
| Name | Math | Physics | Average grade |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
“数学”和“物理”栏供用户输入数字,“平均”栏不能输入数值,它仅用于显示用户输入“数学”和“物理”成绩后的平均值。如何禁用编辑但仍在“平均值”列中显示计算值?
我想将内容写入多行,但我的代码不起作用
ui->tableWidget->setColumnCount(4);
ui->tableWidget->setRowCount(8);
ui->tableWidget->setSortingEnabled(false);
QTableWidgetItem *newItem = new QTableWidgetItem(tr("Hello World"));
for (int i=0; i< ui->tableWidget->rowCount(); i++)
ui->tableWidget->setItem(i, 0, newItem);
Run Code Online (Sandbox Code Playgroud)有一条消息是这样的
QTableWidget: cannot insert an item that is already owned by another QTableWidget
Run Code Online (Sandbox Code Playgroud)
我还是不明白,因为我是QT的新手。请帮助我,非常感谢!:)
更新代码:
for (int i = 0; …Run Code Online (Sandbox Code Playgroud) 我知道很多人都问过这个问题.我也在这里搜索过它.最简单的解决方案之一是样式表:
QRadioButton {
background-color: rgb(252,254,252);
color: black;
}
QRadioButton::indicator {
width: 11px;
height: 11px;
border-radius: 5px;
}
QRadioButton::indicator::unchecked{
border: 1px solid;
border-color: rgb(132,132,132);
border-radius: 5px;
background-color: white;
width: 11px;
height: 11px;
}
QRadioButton::indicator::checked{
border: 3px solid;
border-color: white;
border-radius: 6px;
background-color: rgb(0,116,188);
width: 7px;
height: 7px;
}
Run Code Online (Sandbox Code Playgroud)
但如果我这样做,结果就像这样
(按钮只有白色圆形边框,内部为蓝色圆形).但是,我们可以在它们之外制作黑色边框,就像标准的单选按钮一样
?(黑色边框 - >白色边框 - >蓝色圆形).我们可以在Qt中做到吗?
我创建了一个委托,需要识别 mouseOver 状态来构建效果。但这不起作用。当我的表格出现时,输出如下

我没有看到 MouseOver 状态。我怎样才能认出它?
void TableDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
qDebug() << option.state;
if ( option.state == QStyle::State_MouseOver )
{
painter->fillRect( option.rect, QColor( 249, 126, 18 ) );
}
}
Run Code Online (Sandbox Code Playgroud) qt ×4
c++ ×2
css ×1
delegates ×1
formatting ×1
mouseover ×1
qlineedit ×1
qradiobutton ×1
qstyle ×1
qstylesheet ×1
qt5 ×1
qtableview ×1
qtablewidget ×1
sql ×1
sqlite ×1